在与Rails应用程序相同的域上运行Wordpress的最佳方法是什么? [英] What's the best way to run Wordpress on the same domain as a Rails application?

查看:86
本文介绍了在与Rails应用程序相同的域上运行Wordpress的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个标准的Rails应用,其中Nginx和Mongrel在 http://mydomain 上运行.我需要在 http://mydomain.com/blog 上运行Wordpress博客.我的首选是将博客托管在运行在同一服务器或单独的服务器上的Apache中,但我不希望用户在URL中看到其他服务器.那有可能吗?如果没有,您会建议如何实现这一目标?

I've got a standard Rails app with Nginx and Mongrel running at http://mydomain. I need to run a Wordpress blog at http://mydomain.com/blog. My preference would be to host the blog in Apache running on either the same server or a separate box but I don't want the user to see a different server in the URL. Is that possible and if not, what would you recommend to accomplish the goal?

推荐答案

我认为joelhardi的解决方案优于以下解决方案.但是,在我自己的应用程序中,我希望将博客保留在与Rails站点不同的VPS上(内存问题的分离).要使用户看到相同的URL,请使用与代理杂种群集通常相同的代理技巧,除了代理另一盒上的端口80(或其他端口).十分简单.对用户而言,它就像代理mongrel一样透明-他们仅看到" NGINX在您域的端口80上进行响应.

I think joelhardi's solution is superior to the following. However, in my own application, I like to keep the blog on a separate VPS than the Rails site (separation of memory issues). To make the user see the same URL, you use the same proxy trick that you normally use for proxying to a mongrel cluster, except you proxy to port 80 (or whatever) on another box. Easy peasy. To the user it is as transparent as you proxying to mongrel -- they only "see" the NGINX responding on port 80 at your domain.

upstream myBlogVPS {
        server 127.0.0.2:80;  #fix me to point to your blog VPS
}

 server {
    listen       80;


    #You'll have plenty of things for Rails compatibility here

    #Make sure you don't accidentally step on this with the Rails config!

    location /blog {
        proxy_pass         http://myBlogVPS;
        proxy_redirect     off;

        proxy_set_header   Host             $host;
        proxy_set_header   X-Real-IP        $remote_addr;
        proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
    }

您可以使用此技巧让Rails随便使用您想要的任何服务器技术.直接代理到适当的服务器/端口,NGINX会将其隐藏在外部.此外,由于所有URL都指向同一个域,因此只要正确地编写URL,您就可以无缝集成基于PHP的博客,基于Python的跟踪系统和Rails应用.

You can use this trick to have Rails play along with ANY server technology you want, incidentally. Proxy directly to the appropriate server/port, and NGINX will hide it from the outside world. Additionally, since the URLs will all refer to the same domain, you can seemlessly integrate a PHP-based blog, Python based tracking system, and Rails app -- as long as you write your URLs correctly.

这篇关于在与Rails应用程序相同的域上运行Wordpress的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆