Multiple reverse proxies that read from /static/?

Hello,

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
proxy
(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
proxy_pass http://127.0.0.1:8000/;
}

location /ipython {
#ipython notebook server (tornado) running on localhost port 9999
proxy_pass http://127.0.0.1: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
nest
a location /static/ inside the other blocks? Intuitively nesting
doesn’t
work, because the css is calling /static, not /ipython/static or
/django/static.

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

Thanks in advance.

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,249943,249943#msg-249943

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
one
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
collision
occurring due to an upgrade of either app.

I would either a) see if you can modify the static files location for
the
apps, or serve one / both off a subdomain - notebook.mysite.com or
similiar. If you really want to try the “merge” approach, try_files
http://nginx.org/en/docs/http/ngx_http_core_module.html#try_files might
be
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]
http://mailman.nginx.org/mailman/listinfo/nginx


Matt G.
API Developer

T: +44(0)207 099 7777
E: [email protected]
W:
www.7digital.comhttp://www.google.com/url?q=http%3A%2F%2Fwww.7digital.com&sa=D&sntz=1&usg=AFrqEzeLlO75mVeA-8Yi-niLjEpFokXaYA

This email, including attachments, is private and confidential. If you
have
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
any
attachment. Any unauthorised copying of this message or unauthorised
distribution and publication of the information contained herein are
prohibited.

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
are
configured in your django project settings.py
(https://docs.djangoproject.com/en/1.6/ref/settings/#std:setting-STATIC_URL).
Ipython notebook static url prefixes are configured in the
NotebookApp.webapp settings
(http://ipython.org/ipython-doc/rel-1.1.0/interactive/public_server.html#running-with-a-different-url-prefix).

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

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,249943,249996#msg-249996

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs