Linking Rails and Wordpress Applications on Different Hosts

I installed the Rails app on VPS and the WordPress blog on GoDaddy. I did this because I do not want to install PHP on my VPS. In addition, my rails application uses Postgres, and although I know that WordPress can be configured to use Postgres, I just don't want to worry.

How to connect the blog and the application with rails so that the blog is located at:

www.mysite.com/blog

In addition, when navigating the blog internally, the base URL should remain www.mysite.com/blog

For example:

www.mysite.com/blog/article1

www.mysite.com/blog/category

And so on....

+7
ruby-on-rails ruby-on-rails-3 wordpress
source share
3 answers

Assuming your Rails site is running with Apache in front, here is what you can put in the VirtualHost part of your Rails site:

 <Location /blog> ProxyPass http://godaddy.com/yourwordpress-site/ </Location> 

In Nginx, it will look like

 location /blog { proxy_pass http://godaddy.com/yourwordpress-site; } 

Of course, I would recommend that you add a few more parameters to the proxy server settings in order to keep the IP address of the original requester, etc. By doing this, the web server already catches the request and does not even bother you with a Rails application with requests that it really does not know about.

+8
source share

redirect correctly but not hide wordpress website url

in your rails routes.rb application

 match "/blog" => redirect("http://YOUR_WORDPRESS_BLOG_SITE_URL") 

Make sure you remember to add http / https to the redirect URL

+4
source share

Another alternative is to use a subdomain (instead of a subfolder), for example blog.mysite.com , and then it can be processed using simple and simple dns.

+3
source share

All Articles