Prefix path with Tornado apps

69 views
Skip to first unread message

Aleksandar Radulovic

unread,
Aug 27, 2011, 1:25:03 PM8/27/11
to python-...@googlegroups.com
Hi guys,

I'm looking for a neat way to run few tornado apps behind nginx with
different prefixes. What I'm trying to achieve is smth like this:

upstream app1 {
server http://127.0.0.1:5001;
}

upstream app2 {
server http://172.0.0.1:6001;
}

server {
location /app1 {
proxy_pass @app1;
}
location /app2 {
proxy_pass @app2;
}
}

Now, this is all fine except for one thing - my apps get the full URIs
(prepended with "location" paths) and that's not really what I want:
GET /app1/some_url_in_app1
GET /app2/some_url_in_app2

I don't really want to change routes configuration in the apps, but
rather have some configurable prefix that Tornado automagically adds
in front of the paths (something like PrefixMiddleware in Pylons).

Is there such thing or should I start writing my own? ;)

Thanks for your help,
alex.

--
a lex 13 x
http://www.a13x.info

Ben Darnell

unread,
Aug 27, 2011, 4:11:06 PM8/27/11
to python-...@googlegroups.com
There's nothing like this currently.  You could try using nginx's rewrite module to strip the prefix before sending the request on to the backends.

-Ben
Reply all
Reply to author
Forward
0 new messages