次のように、https://blog.csdn.net/liuxiao723846/article/details/54925328 の方法に従って、非認識バージョンのアップグレードを実行してみてください。
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;
}
私の実際の構成は次のとおりです。
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/;
しかし、エラーが報告されました
"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
こちらの記事 https://blog.csdn.net/fjh1997/article/details/98751574 に従って削除しました/
が、使用できません。パスの問題である可能性があります。サーバーは 401 ユーザーがログインしていないと報告し続けます。
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/;
この記事 https://www.cnblogs.com/woshimrf/p/nginx-proxy-rewrite-url.html を読んで解決し、最終的にリライトを追加しました
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/;