设置Nginx配置时遇到问题。 如果我将配置设置为代理到IP地址,则可以使用,但是如果我替换它以将IP作为查询参数来获取,则它将失败。
a。终点:/ serviceA /
rewrite ^/serviceA$ $scheme://$http_host/serviceA/ permanent;
location /serviceA/ {
rewrite ^/serviceA/(.*)$ /$1 break;
proxy_pass http://10.208.21.186:8788;
proxy_redirect http://10.208.21.186:8788/ $scheme://$http_host/serviceA/;
proxy_set_header Connection $connection_upgrade;
proxy_http_version 1.1;
proxy_read_timeout 20d;
}
以上解决方案有效。但是,如果我替换读取作为查询参数发送的ip,它将失败
rewrite ^/serviceA/(.*)$ $scheme://$http_host/serviceA/ permanent;
location /serviceA/ {
rewrite ^/serviceA/(.*)$ /$1 break;
proxy_pass http://$arg_ip:8788;
proxy_redirect http://$arg_ip:8788/ $scheme://$http_host/serviceA/;
proxy_set_header Connection $connection_upgrade;
proxy_http_version 1.1;
proxy_read_timeout 20d;
}