Rewriting Base URL when passing

adam estes wtymdjs at gmail.com
Wed Feb 15 18:53:56 UTC 2012


The problem is that its not going to be just /admin

There are around 10 urls defined.

I tried

location ~ ^/django(?P<django_path>.*?)$ {
                        uwsgi_param PATH_INFO $django_path;
                        uwsgi_pass 127.0.0.1:9001;
                        include uwsgi_params;
                }


Which according to RegSkinner, would match anything after /django

But this did not work. Its still passing the django parth. What do I do?

On Wed, Feb 15, 2012 at 1:08 PM, Valentin V. Bartenev <ne at vbart.ru> wrote:

> On Wednesday 15 February 2012 21:32:30 adam estes wrote:
> > I'm trying to setup Django through UWSGI using Nginx.
> >
> > I got the UWSGI pass to work using this function
> >
> >                 location / {
> >                         include        uwsgi_params;
> >                         uwsgi_pass     127.0.0.1:9001;
> >                 }
> > Unfortunately when I visit /django/admin. I get an error
> >
> > Page not found (404) Request Method: GET Request URL:
> > http://69.x.x.x/django/admin Using the URLconf defined in Django.urls,
> > Django tried these URL patterns, in this order: ^admin/
> >
> > How can I have nginx rewrite the url to not pass the /django part?
>
> You can use "rewrite" directive:
>
>  http://nginx.org/en/docs/http/ngx_http_rewrite_module.html#rewrite
>
> Or regexp "location" with captures and correspond uwsgi_param setting.
>
>  http://nginx.org/en/docs/http/ngx_http_core_module.html#location
>
> i.e.:
>
>  location /django/ {
>
>     location ~ ^/django(?P<adm_path>/admin/.+)$ {
>         uwsgi_param  PATH_INFO  $adm_path;
>         ...
>     }
>
>  }
>
>  wbr, Valentin V. Bartenev
>
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20120215/347b14ae/attachment.html>


More information about the nginx mailing list