listen proxy_protocol and rewrite redirect scheme

adrhc nginx-forum at
Fri Sep 16 15:12:16 UTC 2016

Hi, I have this setup:

the browser request (https on 443) is received by sshttp which sends it to
stunnel:1443 which proxy it to nginx:1080.
When nginx receives the request it has $scheme = "http"; so, for any rewrite
with "permanent" or "redirect" the Location header uses "http" while I
really need "https" scheme.

Is there any way for forcing nginx to change $scheme according to my will? 
or at least to generate the Location header with no scheme or with my
desired scheme?

Thank you

nginx configuration:
	server {
		listen proxy_protocol;
		port_in_redirect		off;
		server_name_in_redirect	off;

stunnel configuration:
accept = ************:1443
connect =
protocol = proxy
sni =
[www on any]
sni = tls:*
connect =
protocol = proxy

Posted at Nginx Forum:,269623,269623#msg-269623

More information about the nginx mailing list