Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Set up <code>X-Forwarded-Port</code> in Varnish. See <a href="http://www.cynapse.com/community/home/cyn.in-users/varnish-configuration" rel="nofollow">this example</a> and the other results from a Google search for "<a href="http://www.google.com/search?sourceid=chrome&amp;ie=UTF-8&amp;q=varnish+x-forwarded-port" rel="nofollow">varnish x-forwarded-port</a>".</p> <p>You must also, of course, set up <code>X-Forwarded-For</code> and <code>X-Forwarded-Proto</code>.</p> <hr> <p>The headers <code>X-Forwarded-For</code>, <code>X-Forwarded-Proto</code>, and <code>X-Forwarded-Port</code> are a way for HTTP reverse proxies such as Nginx, Squid, or Varnish to communicate to the "back-end" HTTP application server, your Rails application running in Thin or Unicorn, who the user actually is and how the user actually connected.</p> <p>For example, suppose you have Nginx in front of your Rails application. Your Rails application was booted with Thin and is listening on 127.0.0.1:8080, while Nginx is listening on 0.0.0.0:80 for HTTP and 0.0.0.0:443 for HTTPS. Nginx is configured to proxy all connections to the Rails app. Then your Rails app will think that any user's IP address is <code>127.0.0.1</code>, the port is <code>8080</code>, and the scheme is <code>http</code>, even if the actual user connected from <code>1.2.3.4</code> and requested the page via <code>https</code> on port <code>443</code>. The solution is to configure Nginx to set the headers:</p> <pre><code>X-Forwarded-For: 1.2.3.4 X-Forwarded-Scheme: https X-Forwarded-Port: 443 </code></pre> <p>and the Rails app should use these parameters instead of the default ones.</p> <p>The same applies for whatever reverse proxy you use, such as Varnish in your case.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload