The effect I want:
http://hostname/proxy/3000
http://127.0.0.1:3000
http://hostname/proxy/3000/anything
http://127.0.0.1:3000/anything
There is a requirement: the port is changed
I tried
location ~ /proxy/(\d+) {
proxy_pass http://127.0.0.1:;
rewrite ^/(.*)$ / break;
}
But rewrite has problems no matter how it is written
How to write in nginx configuration, wait online~
proxy_pass
的文档里有讲:location
使用了正则后,proxy_pass
The URI part in the parameters following the directive will be ignored. You can use the following configuration to indirectly achieve the function you want: