首頁  >  問答  >  主體

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

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路由不匹配。

大家讲道理大家讲道理2713 天前472

全部回覆(1)我來回復

  • PHP中文网

    PHP中文网2017-05-16 17:17:51

    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/(.*)$ / break;
            proxy_pass http://localhost:3000;
        }
    }

    rewrite一下

    回覆
    0
  • 取消回覆