I've got some special setup to do for my Rails app. My app is hosted behind a reverse proxy and it is for some reason rewriting the requests. The server the app runs on only has an internal IP address. The reverse proxy has the public address and redirects all incoming requests to the app server.
The problem is, while all requests come in as example.com/my/url
they are being rewritten and sent to the app server as 10.0.0.2/my/url
. This becomes a problem when e.g. devise comes into play by requiring authentication and redirecting to the login page. The redirect sent will include the local IP address instead of the FQDN that was originally requested.
Any idea how I can tell my Rails app to use a specific hostname in redirects? I've tried setting HTTP_HOST
using passenger_set_cgi_param
which didn't work and also tried to manually set request.host
in a before_filter
.