Multiple reverse proxies that read from /static/?


Sorry for the beginner question, but I can’t seem to find an example
anywhere that shows how to handle nginx hosting more than one reverse
(such as a Django app and an Ipython notebook) where both systems have
static files in different directories.

The relevant parts of my nginx conf look something like this -

location /django {
#gunicorn server running on localhost port 8000

location /ipython {
#ipython notebook server (tornado) running on localhost port 9999

location /static {
alias /opt/django/django_project/static/;
#alias /usr/lib/python2.6/site-packages/IPython/html/static/;

Is there a way to specify two different directories of static files or
a location /static/ inside the other blocks? Intuitively nesting
work, because the css is calling /static, not /ipython/static or

My end goal would be to go to to see my Django
pages and to get to my ipython notebook
Either one works right now if I point location /static {} to the
alias, but I don’t know how to get both working at the same time.

Thanks in advance.

Posted at Nginx Forum:

I think your comment “intuitively nesting doesn’t work” is correct - you
wish to merge the uri spaces of django and ipython into one, which means
that if both apps need (eg) /static/css/main.css, they will collide and
app will always get the wrong file. It might be that you can avoid
collisions of this type by chance, but then you run the risk of
occurring due to an upgrade of either app.

I would either a) see if you can modify the static files location for
apps, or serve one / both off a subdomain - or
similiar. If you really want to try the “merge” approach, try_files
Module ngx_http_core_module might
of use.

On 8 May 2014 20:50, kafonek [email protected] wrote:

#gunicorn server running on localhost port 8000
#alias /usr/lib/python2.6/site-packages/IPython/html/static/;

Either one works right now if I point location /static {} to the
[email protected]
nginx Info Page

Matt G.
API Developer

T: +44(0)207 099 7777
E: [email protected]

This email, including attachments, is private and confidential. If you
received this email in error please notify the sender and delete it from
your system. Emails are not secure and may contain viruses. No liability
can be accepted for viruses that might be transferred by this email or
attachment. Any unauthorised copying of this message or unauthorised
distribution and publication of the information contained herein are

7digital Limited. Registered office: 69 Wilson Street, London EC2A 2BB.
Registered in England and Wales. Registered No. 04843573.

Yep, thanks Matt.

In case anyone else runs across this post, Django static url prefixes
configured in your django project
Ipython notebook static url prefixes are configured in the
NotebookApp.webapp settings
(Running a notebook server — IPython 1.2.1: An Afternoon Hack documentation).

I was definitely trying to tackle the problem the wrong way.

Posted at Nginx Forum: