How can I integrate WordPress with my Rails app under one domain?

I have a Rails application currently running with Nginx and Mongrel at my main domain. Now I want to add a WordPress blog that users can access at mydomain.com/blog without seeing any different server names in the URL.

My ideal setup would be hosting the WordPress site on Apache, either on the same server or a different machine entirely. The key requirement is that visitors shouldn’t notice they’re being served from different applications or servers.

Is this kind of setup achievable? If so, what’s the most reliable approach to make it work smoothly? I’m open to alternative solutions if my preferred method has significant drawbacks.

Had this exact problem a few years ago. I ended up using a subdomain instead - blog.mydomain.com for WordPress, main domain stayed on Rails. Thought I needed everything under one path at first, but the subdomain was way easier to maintain. If you really want /blog though, try Nginx upstream blocks. Set up Rails and WordPress as separate upstreams, then use location directives to split the traffic. Just make sure sessions don’t clash between apps, and watch for cookie conflicts if both try setting similar session variables.

for sure! you can use nginx as a reverse proxy. just set it to route /blog to your apache while the rest stays on rails. it’s been solid for me over the years, no issues!

I’ve done exactly this on my production site. Skip Apache entirely - just use Nginx to serve WordPress files directly and proxy everything else to Rails. Way less overhead and much easier to maintain. Set up location blocks in your Nginx config so /blog hits your WordPress directory, then let PHP-FPM handle the processing. Make sure WordPress connects to the right database. The only tricky bit is getting permalink rewrites working, but once that’s sorted, it runs way better than two separate servers and users can’t tell the difference.