7

I have setup my Rails app on a VPS and a WordPress blog on GoDaddy. I did this because I don't want to have to install PHP on my VPS. Also, my rails app is using Postgres and while I am aware that WordPress can be setup to use Postgres, I just don't want to go through the hassle.

How do I link the blog and my rails app, such that the blog is located at:

www.mysite.com/blog

Also, when internally navigating on the blog, the base URL should remain www.mysite.com/blog

For example:

www.mysite.com/blog/article1

www.mysite.com/blog/category

And so on....

pratski
  • 1,448
  • 2
  • 22
  • 37

3 Answers3

8

Assuming that your Rails site runs with an Apache in front, here is something you can put into the VirtualHost part of your Rails site:

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

In Nginx it would look like this

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

Of course I would recommend, that you add some more options to the proxy setup so that the IP address of the original requester is kept etc. Doing it this way, the Webserver already catches the request and doesn't even bother your Rails app with requests that it doesn't really know about.

Christoph Eicke
  • 1,134
  • 7
  • 15
  • The simpler solution is to add a DNS entry for the GoDaddy site. But there's more to consider. – Tom Harrison Aug 12 '13 at 03:20
  • How does adding DNS entries help with what @pratski wants? Please read the question. – Christoph Eicke Aug 12 '13 at 07:39
  • You're correct, I misread the question. While I am not sure the proxy_pass solution is appropriate, I don't have anything better until putting more thought into it. – Tom Harrison Aug 13 '13 at 12:38
  • Having `ProxyPass` in here you can hide that you have a GoDaddy blog and everything goes through your domain, good for seeing who accesses what etc. – Christoph Eicke Aug 13 '13 at 14:25
  • What exactly is the VirtualHost part of a rails site? – John Curry Nov 10 '14 at 06:33
  • It's a configuration directive for the web server (e.g. Apache, Nginx) that sits in front of the Rails app and handles the actual client requests. See here for Apache: http://httpd.apache.org/docs/current/vhosts/examples.html – Christoph Eicke Nov 10 '14 at 07:49
4

to redirect correctly, but not hide the url of the wordpress site

in your rails app's routes.rb

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

Make sure you didn't forget to add http/https in your redirection url

Muntasim
  • 6,689
  • 3
  • 46
  • 69
3

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

nathanvda
  • 49,707
  • 13
  • 117
  • 139