title: Change hostname for redirect in Rails using Devise
body: <p>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.</p>
  
  <p>The problem is, while all requests come in as <code>example.com/my/url</code> they are being rewritten and sent to the app server as <code>10.0.0.2/my/url</code>. 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.</p>
  
  <p>Any idea how I can tell my Rails app to use a specific hostname in redirects? I've tried setting <code>HTTP_HOST</code> using <code>passenger_set_cgi_param</code> which didn't work and also tried to manually set <code>request.host</code> in a <code>before_filter</code>.</p>