
1 lecher 2016-02-04 15:27:18 +08:00 via Android location / { if (!-e $request_filename) { proxy_pass http://xx.xx.xx.xx:20002; } index index.html index.htm; } if 的判断是,如果指定路径不存在文件,则执行判断内的语句,将请求转发给代理端口。 |
3 seki 2016-02-04 15:33:18 +08:00 |
4 lution 2016-02-04 15:41:24 +08:00 用 try_files 试试 rewrite ^/$ /index.html redirect; location / { root /www/main; try_files $uri @python_proxy; } location @python_proxy { proxy_pass http://127.0.0.1:20002; } |
5 lecher 2016-02-04 15:50:42 +08:00 via Android @hayao650 因为你的正则没有指定起始和结束符,所以,实际上你写的两个正则匹配的结果是一样的。 Nginx 中要指定仅匹配 / 的正则写法是: ^/$强制限定只匹配 /。 我这个写法是不太好维护的。不如看看 seki 给的连接,试试 try_files 的语法,这个可以方便你指派多个规则跳转到同一个代理端口。维护起来更省事一些。 |
6 hayao650 OP OK ,谢谢各位了,学习了 |
7 xujif 2016-02-04 16:18:39 +08:00 via iPhone ~才用正则,=应该是直接匹配的,再把,=/index.html 加上尝试下? |