I have a client who wants to migrate his Rails app to Heroku. However the client also has a blog associated with his domain that runs on WordPress. Currently, the WordPress blog is running happily alongside the Rails app, but once we migrate to Heroku, that clearly won't be possible.
我有一个客户想把他的Rails应用程序移植到Heroku。但是客户也有一个与他的域相关的博客,在WordPress上运行。目前,WordPress博客与Rails应用一起运行得很好,但是一旦我们迁移到Heroku,这显然是不可能的。
The url for the app is like http://mydomain.com, and the url for the blog is like http://mydomain/blog.
应用程序的url类似于http://mydomain.com,而博客的url类似于http://mydomain/blog。
I realize that the best long-term solution is to redo the blog in a Rails format like Toto or Jekyll. But in the short term, what is the best way to continue hosting the WP blog where it is (or somewhere) but use Heroku to run the app? The client doesn't want the blog to be on a subdomain, but to remain at mydomain/blog for SEO reasons and also since there is traffic to the blog. I have two ideas:
我意识到,最好的长期解决方案是用Toto或Jekyll之类的Rails格式重新编写博客。但是在短期内,什么是继续在WP博客所在地(或其他地方)托管而使用Heroku运行应用程序的最佳方式?客户不希望博客在子域名上,而是为了搜索引擎优化的原因而留在mydomain/blog,并且因为博客有流量。我有两个想法:
-
Use rack_rewrite or refraction (or just a regular old 301 and Apache mod_rewrite) on the old (non-Heroku) server to redirect the main url from the old site to Heroku. In this case, I can just leave the Wordpress blog running happily where it is. I think?? Is there a reason to choose one of those options (rack_rewrite, refraction, or mod_rewrite) over the others if I do it this way?
在旧服务器(非Heroku)上使用rack_rewrite或refraction(或者普通的301和Apache mod_rewrite)将主url从旧站点重定向到Heroku。在这种情况下,我可以让Wordpress博客在它所在的位置上快乐地运行。我觉得? ?如果我这样做的话,是否有理由选择其中一个选项(rack_rewrite,折射,或者mod_rewrite) ?
-
Switch the DNS info to point to the Heroku site, and then use a 301 redirect from the blog to the old site. But then I'll have to get the old (non-Heroku) site on a subdomain and use some kind of rewrite rules anyway so it looks like it isn't a subdomain.
将DNS信息转换为指向Heroku站点,然后使用301重定向从博客跳转到旧站点。但是我必须把旧的(非heroku)站点放在子域上,并使用某种重写规则,这样它看起来就不是子域了。
Are either of these approaches preferable, or is there another way to do it that's easier that I'm missing?
这两种方法是更可取的,还是有另一种方法更容易让我忽略?
3 个解决方案
#1
1
The only tenable long term/scalable solution would be to host the blog permanently on a sub-domain or different domain and add a redirect from mydomain.com/blog to the new location (ie: blog.mydomain.com).
唯一站得住脚的长期/可扩展解决方案是将博客永久地托管在子域或不同域上,并将mydomain.com/blog的重定向添加到新位置(即:blog.mydomain.com)。
You would need a single server running a front-end like Apache/nginx on mydomain.com to serve up mixed back-ends like Rails and Wordpress and that is not possible on Heroku.
你需要一个运行前端的服务器,比如mydomain.com上的Apache/nginx,来提供Rails和Wordpress等混合后端服务,这在Heroku上是不可能的。
Sadly, this is where you need to dig in as a consultant and be stern with your client about the technical limitations.
遗憾的是,这正是您需要作为一名咨询师深入研究的地方,并在技术限制方面对您的客户保持严厉的态度。
Why does you client want to migrate to Heroku? Is there a larger goal behind that you could accomplish with different hosting where you control the front-end and can mix in different back ends?
为什么您的客户想要迁移到Heroku?是否有一个更大的目标,你可以完成与不同的主机,你可以控制前端,可以混合在不同的后端?
#2
1
Another solution is to set heroku to http://app.example.com, and Wordpress to http://example.com. You put your Wordpress-landing page in the root , and blog on /blog. When the user click "login" or "signup" on the landing-page, they're linked to the heroku-app.
另一个解决方案是将heroku设置为http://app.example.com,将Wordpress设置为http://example.com。你把你的word - press-landing页面放在根目录中,然后把博客放到/blog中。当用户在登录页面上点击“登录”或“注册”时,就会链接到heroku-app。
This will be optimal in a SEO-perspective, but require some DNS-knowledge.
这在视觉上是最理想的,但是需要一些神经学知识。
#3
1
Winfield's answer is not correct. You can run a reverse proxy on your rack server (via Heroku) to direct to the blog, wherever it may be.
温菲尔德的回答不正确。您可以在您的机架服务器(通过Heroku)上运行反向代理,将其指向博客,无论它在哪里。
See https://github.com/jaswope/rack-reverse-proxy
参见https://github.com/jaswope/rack-reverse-proxy
After you install the gem and set up your app according to the docs, your ./config.ru
file will have something like this:
在您安装gem并根据docs设置应用程序之后,您的./config.ru文件将具有如下内容:
use Rack::ReverseProxy do
reverse_proxy(/^\/blog(\/.*)$/,
'http://<app-name>.herokuapp.com$1',
opts = {:preserve_host => true})
end
#1
1
The only tenable long term/scalable solution would be to host the blog permanently on a sub-domain or different domain and add a redirect from mydomain.com/blog to the new location (ie: blog.mydomain.com).
唯一站得住脚的长期/可扩展解决方案是将博客永久地托管在子域或不同域上,并将mydomain.com/blog的重定向添加到新位置(即:blog.mydomain.com)。
You would need a single server running a front-end like Apache/nginx on mydomain.com to serve up mixed back-ends like Rails and Wordpress and that is not possible on Heroku.
你需要一个运行前端的服务器,比如mydomain.com上的Apache/nginx,来提供Rails和Wordpress等混合后端服务,这在Heroku上是不可能的。
Sadly, this is where you need to dig in as a consultant and be stern with your client about the technical limitations.
遗憾的是,这正是您需要作为一名咨询师深入研究的地方,并在技术限制方面对您的客户保持严厉的态度。
Why does you client want to migrate to Heroku? Is there a larger goal behind that you could accomplish with different hosting where you control the front-end and can mix in different back ends?
为什么您的客户想要迁移到Heroku?是否有一个更大的目标,你可以完成与不同的主机,你可以控制前端,可以混合在不同的后端?
#2
1
Another solution is to set heroku to http://app.example.com, and Wordpress to http://example.com. You put your Wordpress-landing page in the root , and blog on /blog. When the user click "login" or "signup" on the landing-page, they're linked to the heroku-app.
另一个解决方案是将heroku设置为http://app.example.com,将Wordpress设置为http://example.com。你把你的word - press-landing页面放在根目录中,然后把博客放到/blog中。当用户在登录页面上点击“登录”或“注册”时,就会链接到heroku-app。
This will be optimal in a SEO-perspective, but require some DNS-knowledge.
这在视觉上是最理想的,但是需要一些神经学知识。
#3
1
Winfield's answer is not correct. You can run a reverse proxy on your rack server (via Heroku) to direct to the blog, wherever it may be.
温菲尔德的回答不正确。您可以在您的机架服务器(通过Heroku)上运行反向代理,将其指向博客,无论它在哪里。
See https://github.com/jaswope/rack-reverse-proxy
参见https://github.com/jaswope/rack-reverse-proxy
After you install the gem and set up your app according to the docs, your ./config.ru
file will have something like this:
在您安装gem并根据docs设置应用程序之后,您的./config.ru文件将具有如下内容:
use Rack::ReverseProxy do
reverse_proxy(/^\/blog(\/.*)$/,
'http://<app-name>.herokuapp.com$1',
opts = {:preserve_host => true})
end