Der Effekt, den ich will:
http://hostname/proxy/3000
http://127.0.0.1:3000
http://hostname/proxy/3000/anything
http://127.0.0.1:3000/anything
Es besteht eine Vorgabe: Der Port wird ge?ndert
Ich habe es versucht
location ~ /proxy/(\d+) {
proxy_pass http://127.0.0.1:;
rewrite ^/(.*)$ / break;
}
Aber das Umschreiben hat Probleme, egal wie es geschrieben ist
So schreiben Sie in der Nginx-Konfiguration und warten online ~
proxy_pass
的文檔里有講:location
使用了正則后,proxy_pass
指令后面的參數(shù)中的 URI 部分會被忽略??梢允褂孟旅娴呐渲瞄g接達到你想要的功能:
server {
listen 80;
server_name localhost;
location /proxy/ {
rewrite ^/proxy/(\d+)/(.*) /internal?port=$1&url=$2 last;
}
location /internal {
internal;
proxy_pass http://127.0.0.1:$arg_port/$arg_url;
}
}