http, https issue

Maxim Dounin mdounin at
Fri Jan 18 13:31:12 MSK 2008


On Fri, Jan 18, 2008 at 10:54:13AM +0100, Ricardo Acras wrote:

>An??bal Rojas wrote:
>> Please provide you nginx.conf file

>  server {
>    # port to listen on. Can also be set to an IP:PORT
>    listen 8081 default;
>    location / {
>      index index.html index.htm
>      # needed to forward user's IP address to rails
>      proxy_set_header  X-Real-IP  $remote_addr;
>      # needed for HTTPS
>      proxy_set_header  X-FORWARDED_PROTO https;

So you setting X-FORWARDER_PROTO header to 'https' for non-https 
connection. Probably this is the reason why your app uses https:// 
in redirect.

Hint: if you want to preserve this lines identical between http 
and https servers (e.g. for using identical include file or just 
describing them at http{} level instead of doing so in location{}), you 
may try using $scheme variable. I.e.:

-    proxy_set_header  X-FORWARDED_PROTO https;
+    proxy_set_header  X-FORWARDED_PROTO $scheme;

Maxim Dounin

More information about the nginx mailing list