各位好,我发现同样的配置 在 nginx/1.10.2 下 和 在 Tengine/2.2.3 (nginx/1.8.1) 工作有点问题。 具体表现为 post 请求, https 协议访问 后端返回的是 http 协议,java 程序 使用 request.getScheme()获取的协议。
配置如下
`upstream tgauth {
server 172.31.10.43:8003;
server 172.31.10.44:8003;
}
server {
listen 80;
server_name ngauth.test.com tgauth.test.com;
index index.jsp default.jsp;
charset utf-8;
access_log /var/log/nginx/access.ngauth.test.com.log main;
error_log /var/log/nginx/error.ngauth.test.com.log;
location / {
proxy_pass http://tgauth;
proxy_redirect off;
proxy_set_header Cookie $http_cookie;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
server { listen 443 ssl; server_name ngauth.test.com tgauth.test.com; ssl on; ssl_certificate /etc/nginx/conf.d/test.com.crt; ssl_certificate_key /etc/nginx/conf.d/test.com.key; ssl_session_cache shared:SSL:1m; ssl_session_timeout 5m; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; index index.html index.jsp default.jsp; charset utf-8; access_log /var/log/nginx/access.ngauth.test.com.log main; error_log /var/log/nginx/error.ngauth.test.com.log; location / { proxy_pass http://tgauth; proxy_redirect off; proxy_set_header Cookie $http_cookie; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Proto https; proxy_connect_timeout 240; proxy_send_timeout 240; proxy_read_timeout 240; } } ` 请求协助 上述配置 放在 nginx 下正常 ,放在 tengine 下就不正常