Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So I have a flask application running using uWSGI on Nginx. Nginx is set to call my app at the location /app. So in my flask application I have to take into account the /app part when I map the url to a function. Is there a way to rewrite the nginx file or the uwsgi config.xml file to have the application think it is running from the / directory? And are there any side effects?

Just as an example:

the page links to my module

my module uses Flask, so the route mapping goes like this:

    def hello_world():
        return 'Hello World!'

I am wondering if I can change the config files so I could write:

   def hello_world():
       return 'Hello World!'


share|improve this question

Mount your app in the subdir in uWSGI with

--mount / --callable app --manage-script-name

it should work without modifying code or using wsgi middlewares

share|improve this answer
Is this a change I can make to my uwsgi xml configuration file? – eatonphil Jan 2 '13 at 17:53

I made it work by the following nginx config:

location ~ ^/app {
    charset utf-8;
    include uwsgi_params;
    uwsgi_pass uwsgicluster;
    uwsgi_param SCRIPT_NAME /app;
    uwsgi_modifier1 30;

and run uwsgi with --mount and --mange-script-name as @roberto. eg.

uwsgi --socket\ 
            --pythonpath  . \
            --mount /app=./ \ 
            --manage-script-name \
            --callable app
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.