我试图在http上下文中添加下面的块来设置基于$http_x_forwarded_proto $https :
map $http_x_forwarded_proto $https { default off; https on; }
但configurationtesting失败说:
nginx: [emerg] the duplicate "https" variable in /etc/nginx/nginx.conf:36 nginx: configuration file /etc/nginx/nginx.conf test failed
从1.1.11版本的变化来看,variables$ https变成了一个内部variables。
由于它现在是一个内部的,并且请求本身不是通过HTTP,最好的方法是将这个信息传递给fastcgi处理程序。 这是我在我的nginx.conf(通过包含)
map $http_x_forwarded_proto $fastcgi_https { default ''; https on; }
然后我在处理fastcgi_pass的位置块中有下面的代码
fastcgi_param HTTPS $fastcgi_https; fastcgi_param SERVER_PORT $http_x_forwarded_port;