nginx 如何 反向代理相对的url?

【字号: 日期:2022-07-19浏览:47作者:雯心

问题描述

server { listen 80; server_name www.hehehe.com; charset utf-8;location /test {include uwsgi_params;uwsgi_pass 127.0.0.1:3031; }}

对于 http://hehehe.com/test/index 类似这样的请求反向代理到了 uwsgi 是个django应用

然后我只想要把 /index 这部分的url反响代理过去,,而不是/test/index

现在/test/index 导致我的django的url路由匹配不上。

问题解答

回答1:

server { listen 80 default_server; client_max_body_size 10M; client_body_buffer_size 128k; server_name $host; index index.html; root /website/$host; location / { } location ~ /dev/ {rewrite /dev/(.*)$ /$1 break;proxy_pass http://localhost:3000; }}

rewrite一下

相关文章: