Nginx 动态代理

Nginx dynamic proxy

我正在尝试将捕获的正则表达式组作为 URI 传递。

配置:

location ~ /proxy/(.*?)$ {
   proxy_pass http://;
}


需要:

http://127.0.0.1:9999/proxy/example.com/test/asd.html
代理应该传递给:
http://example.com/test/asd.html


结果:

> curl http://127.0.0.1:9999/proxy/example.com/test/asd.html

<html>
<head><title>404 Not Found</title></head>
<body bgcolor="white">
<center><h1>404 Not Found</h1></center>
<hr><center>nginx</center>
</body>
</html>


错误日志为空。
我在这里错过了什么?谢谢

我尝试查找 NGINX 位置正则表达式以查看正则表达式对象的工作方式(即 // 在 JS 中),这是您应该尝试的方法

 location ~ \/proxy\/(.*?)$ {
 proxy_pass http://;
}

看看是否有帮助