如何在同一个域下使用WP博客代理heroku中的Rails应用程序 [英] How to proxy a rails app in heroku with a WP blog under same domain

查看:134
本文介绍了如何在同一个域下使用WP博客代理heroku中的Rails应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


$ b

  • Heroku上的Rails应用程序服务器mydomain.com

  • 在另一个主机上的WP网站(我可以移动到AWS ..甚至是heroku)



我需要 mydomain.com/blog 服务于WP安装,我不想让它成为SEO的子域名。



我的第一个想法是设置apache / nginx作为AWS上的实例上的反向代理。然而,我担心这种设置不是最佳的,因为后端在不同的服务中。



可以将heroku dyno设置为代理吗?我知道没有办法修改heroku上的系统文件,比如创建一个自定义nginx设置来执行代理。我想知道是否有作为代理的应用程序可以安装在heroku中,然后在heroku中设置博客。



或者建议设置一个AWS实例作为与heroku相同区域的代理(us-west1),并在此设置博客。



我对利弊感兴趣解决方案

我已经解决了与Rails和WP相同的确切问题,



我的配置和结果:


  • 托管Rails应用程序关于heroku(www.sexycrets.com)

  • WP博客托管在另一台服务器上(blog.sexycrets.com)

  • 浏览器请求 www.sexycrets.com/blog 他收到了与浏览时相同的html页面, a href =http://blog.sexycrets.com =nofollow> blog.sexycrets.com 和浏览器中的网址保持不变




    1. 我如何实现它




对SEO有效的一种解决方案是使用gem作为反向代理(我使用Github的drewwed / rack-reverse-proxy)。您可以将其配置为拦截路径/ blog(和/ blog /),这样每次Rails被要求/博客时,它都会通过后端调用加载WP网站并将其返回给用户。从用户浏览器的角度来看,这是一个完全透明的操作,除了引入的延迟。用户浏览器无法知道响应中返回的博客页面是从另一台服务器上载入的,浏览器上的网址仍为www.sexycrets.com/blog。




  • 优点:满足SEO要求

  • 缺点:由于反向代理在引入延迟方面不是非常高效的


    1. 替代




为了完整起见,我尝试的另一个选项是在托管在heroku上的加载WP的静态页面中使用iFrame。问题是,为了避免循环引用,WP博客中的所有链接都必须指向blog.sexycret.com(而不是www.sexycrets.com/blog),这部分地破坏了SEO的目的。




  • 优点:性能非常好,因为它甚至不使用Rails:用户浏览器加载静态的/public/blog/index.html页面,其中包含只是指向WP博客的iFrame

  • 缺点:博客中的链接并未指向主域,而是指向第三层域



希望这有助于!


I have this:

  • A rails app on Heroku that servers mydomain.com
  • A WP site on another hosting (that I can move to AWS .. or even heroku)

I need that mydomain.com/blog serves the WP installation, I DONT want it to be a subdomain for SEO.

My first idea was setup apache / nginx as reverse proxy on a instance on AWS. However I worried that this setup is not optimal as backends are in different services.

It's possible to setup heroku dyno as a proxy? I understand there is no way to modify the system files on heroku, like create a custom nginx setup to do the proxy. I was wondering if there is some application that works as a proxy and can be installed in heroku, next setup the blog in heroku also.

Or it's a good idea to setup an AWS instance as proxy in the same region that the heroku is (us-west1), and setup the blog also there.

I'm interested in the pros and cons of each solution and what would be the best way to go.

解决方案

I had tackled the same exact problem with Rails and WP for quite some time.

My configuration and result:

  • Rails app is hosted on heroku (www.sexycrets.com)
  • WP Blog is hosted on another server (blog.sexycrets.com)
  • When the browser requests www.sexycrets.com/blog he receives the same html page that he would have received if browsing blog.sexycrets.com and the url on the browser remains the same

    1. How I achieved it

One solution that does works well for SEO is to use a gem as reverse proxy (I use drewwed/rack-reverse-proxy from Github). You can configure it to intercept the route "/blog" (and "/blog/") so that every time Rails is asked for /blog it loads your WP site with a backend call and returns it to the user. This is a completely transparent operation from the user browser perspective, aside from the delay introduced. The user browser has no way to know that the blog page returned in the response was loaded from another server, the url on the browser remains "www.sexycrets.com/blog".

  • Pros: SEO requirements are satisfied
  • Cons: Performance since the reverse proxy is not very performant in terms of delay introduced

    1. Alternative

For sake of completeness the other option I tried was to use an iFrame in a static page hosted on heroku that loads the WP. The problem is that in order for it to work avoiding a circular reference all the links in the WP blog have to point to blog.sexycret.com (not www.sexycrets.com/blog) which partly defeats the SEO purpose.

  • Pros: Performance is very good since it is not even using Rails: the user browser loads the static /public/blog/index.html page that contains just the iFrame that points to the WP blog
  • Cons: the links in the blog are not pointing to the main domain but to the 3rd level domain defeating

Hope this helps!

这篇关于如何在同一个域下使用WP博客代理heroku中的Rails应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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