set $envflag "-lan"; if ( $http_cookie ~* "Env-flag=lv" ) { set $envflag "-lv"; } location /itadmin {
去掉/可以正常转发,请求的path不会丢失 proxy_pass http://opCptApi$envflag/;
proxy_redirect http://opCptApi$envflag/ /itadmin/;
} upstream opCptApi-lan{ server 172.17.194.208:8080; } upstream opCptApi-lv{ server 172.17.194.208:8080; }
问题描述假定请求路径:/itadmin/message/platforms/page?pageSize=20¤t=1 nginx的access日志: 58.251.1.132 - - [08/Jan/2020:12:03:41 +0800] "GET /itadmin/message/platforms/page?pageSize=20¤t=1 HTTP/1.1" 404 114 "-" "PostmanRuntime/7.21.0" "-" TLSv1.2 ECDHE-RSA-AES128-GCM-SHA256 xxx.17.194.208:8080 0.009 0.009 crm-sadmin-dev.xxx.xxx nginx无error日志,后端服务收到的请求路径是“ /”,”message/platforms/page?pageSize=20¤t=1“请求路径在nginx层丢失
nginx信息Tengine version: Tengine/2.3.1 nginx version: nginx/1.16.0 built by gcc 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC) built with OpenSSL 1.0.2k-fips 26 Jan 2017 TLS SNI support enabled configure arguments: --with-http_ssl_module