search

Home  >  Q&A  >  body text

How does nginx reverse proxy a relative url?

server {
    listen       80;
    server_name  www.hehehe.com;

    charset utf-8;
    
    location /test {
        include uwsgi_params;
        uwsgi_pass 127.0.0.1:3031;
    }
}

For requests like this at http://hehehe.com/test/index
The reverse proxy reaches uwsgi, which is a django application

Then I just want to proxy the url response of the /index part, not /test/index

Now/test/index causes my django url route to fail to match.

大家讲道理大家讲道理2792 days ago527

reply all(1)I'll reply

  • 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 it

    reply
    0
  • Cancelreply