Try to follow the method here https://blog.csdn.net/liuxiao723846/article/details/54925328 to perform a non-aware version upgrade, as follows:
location / {
root html;
index index.html index.htm index.php;
proxy_redirect off;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_http_version 1.1;
proxy_set_header Connection "";
if ( $query_string ~* "usg=0" ) {
proxy_pass http://local_workera;
}
if ( $query_string ~* "usg=1" ) {
proxy_pass http://local_workerb;
}
if ( $arg_uid ~* "(.*[AB]$)" ) {
proxy_pass http://local_workerf;
}
proxy_pass http://local_workera;
}
My real configuration is as follows:
location /test/ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_redirect off;
if ( $query_string ~* "revision=2268" ) {
rewrite ^/sh/(.*)$ /$1 break;
proxy_pass http://127.0.0.1:7001/;
break;
}
proxy_pass http://127.0.0.1:7001/;
But it reported an error
"proxy_pass" cannot have URI part in location given by regular expression, or inside named location, or inside "if" statement, or inside "limit_except" block in
I removed it according to this article https://blog.csdn.net/fjh1997/article/details/98751574 /
, but it cannot be used. It may be a path problem. The server keeps reporting 401 User is not logged in.
location /test/ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_redirect off;
if ( $query_string ~* "revision=2268" ) {
rewrite ^/sh/(.*)$ /$1 break;
proxy_pass http://127.0.0.1:7001;
break;
}
proxy_pass http://127.0.0.1:7001/;
Solved it by reading this article https://www.cnblogs.com/woshimrf/p/nginx-proxy-rewrite-url.html, and finally added rewrite
location /test/ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_redirect off;
if ( $query_string ~* "revision=2268" ) {
rewrite ^/sh/(.*)$ /$1 break;
proxy_pass http://127.0.0.1:7001;
break;
}
proxy_pass http://127.0.0.1:7001/;