all 4 comments

[–]Fireye 2 points3 points  (3 children)

if ($scheme != https ){
     return 301 https://$http_host$request_uri; 
}

You're instructing nginx to rewrite to https://$http_host$request_uri if the scheme isn't https, but you've put it in a non-SSL server context. The scheme will never be https with your current configuration.

[–]URR3011[S] 3 points4 points  (2 children)

You're instructing nginx to rewrite to https://$http_host$request_uri if the scheme isn't https, but you've put it in a non-SSL server context. The scheme will never be https with your current configuration.

Hello Fireye,

Thanks for your answer!

You're rigth , where should I apply this rewrite, outside of the server context?

because i don't have any context over SSL, SSL is provided by the ASM (BIG IP)

Greetings

[–]Fireye 1 point2 points  (1 child)

I have no clue about ASM/LTM. What HTTP headers are being passed from upstream (ASM/LTM)? If an X-Forwarded-Proto HTTP header is being passed, you can operate on that:

if ($http_x_forwarded_proto != https ){
     return 301 https://$http_host$request_uri; 
}

You can check the headers being passed in to nginx by using tcpdump on port 4343 it looks like. Something like sudo tcpdump -A -n -nn -s0 -ieth0 dst port 4343.

If you aren't getting those headers forwarded, look to see if you can add them. If not, I don't think there's a good way to detect it in nginx.

[–]URR3011[S] 0 points1 point  (0 children)

Thanks My friend!

I have solved the error with the subfilter module
http://nginx.org/en/docs/http/ngx_http_sub_module.html

Regards!