How to edit url and pass forward to wsgi?

Thomas Nyberg tomnyberg at gmail.com
Thu Sep 3 04:44:09 UTC 2015


Hello,

If I have the following directive:

     location ~ /staging/dog/.*/info/cat {
         rewrite /staging/(.+) /$1 break;
         include uwsgi_params;
         uwsgi_pass 127.0.0.1:3130;
     }

then a call to `http://127.0.0.1/staging/doc/v0.2/info/cat` gets passed 
through to my wsgi handler fine. Now if I leave that directive in place, 
but put the following one before it, then get "502 Bad Gateway":

     location ~ /dog/.*/info/cat {
         include uwsgi_params;
         uwsgi_pass 127.0.0.1:3030;
     }

Nothing else was changed. The route is different, the port is different. 
Why would this affect the other one? Is it that I'm somehow "breaking" 
out and _then_ matching the other one?

My question is: how do I _not_ break out? I've tried removing "break" 
but the effect seems exactly the same (i.e. undesired). How do I make it 
so that the url is rewritten and then pass immediately on? I.e. I want 
to _not_ leave the location box once I've matched. Is this possible?

I've searched the internet for a long time and read the docs here: 
http://nginx.org/en/docs/http/ngx_http_rewrite_module.html but I've had 
no success so far. Thanks a lot for any help.

Cheers,
Thomas



More information about the nginx mailing list