这是我的.platform/nginx/conf.d/elasticbeanstalk/00_application.conf,它肯定能正常工作,因为我能很好地获取客户端的主机。但是$http_x_forwarded_proto为null。
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
proxy_set_header X-Request-URI $request;
proxy_set_header X-Request-PATH $request_uri;
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:8080;
proxy_http_version 1.1;
}
client_max_body_size 20M;
字符串
1条答案
按热度按时间4ngedf3f1#
确保填充**$http_x_forwarded_proto头的解决方案包括两个步骤:
1.编辑NLB目标组的属性,并确保启用Proxy protocol v2属性
1.编辑nginx.conf文件,插入proxy_protocol**如下:
字符串
可以将nginx.conf文件放在项目的Web根文件夹的**.platform/nginx/nginx.conf**中