xicreative
xicreative

Reputation: 31

Reverse proxy via Passenger/Nginx on Heroku

I have Rails app on Heroku and need to create a reverse proxy to our blog, which is currently hosted on dreamhost. It was originally hosted at blog.ourdomain.com but we now want ourdomain.com/blog to point to it. From my research it seems like the best to do this is a reverse proxy via the Nginx component of our Passenger application server. So, I've created a location in our nginx.conf.erb:

    location ^~ /blog {
        proxy_pass https://blog.ourdomain.com;
    }

This works just fine for our purposes, EXCEPT when /blog is visited. (/blog/, /blog/whatever/... is fine).

When /blog is used, nginx instead redirects to ourdomain.com:12345/blog/ where the port is what I assume to be our heroku dyno's port. How can I get the slash-less URI to go reverse proxy correctly?

Upvotes: 2

Views: 380

Answers (1)

James Gibson
James Gibson

Reputation: 26

I've run into the same problem as well. We still haven't gotten our proxy fully functioning - running into some weird redirect loops on the WordPress / Apache side - but we did solve this by manually setting the port:

location ^~ /blog {
    proxy_pass https://blog.ourdomain.com:80;
}

I'm not confident enough in my nginx knowledge to say that will work for sure, but it seems to be working for us.

Upvotes: 1

Related Questions