I am using nginx as a proxy to a couple of flask apps, with uwsgi as the middleware. Here's my nginx config for a test app.

server {
    listen      80;
    server_name test.myapp.com www.test.myapp.com;
    charset     utf-8;
    client_max_body_size 250M;
    location / { try_files $uri @testapp; }

location @testapp {
    include uwsgi_params;
    uwsgi_pass unix:/tmp/testapp_uwsgi.sock;

location /forecaster/components/ {
    alias /opt/test/client/app/components/;


I'm pretty sure that nginx is not actually serving the static files though, even if I comment out the location block, the files are getting served from something. I see 200's in the nginx log, as well as 200's in the uWsgi logs. How can you tell which one is serving the static files? I suppose that the flask app could be serving them as well?

/opt/test/client/app/components/ certainly exists, and is readable to others. Is there some way to force uwsgi NOT to handle these requests?

1 Answer 1


You do need a location. But that's not why nginx isn't serving your static files.

The problem is you forgot to specify a root directive in your server block. So nginx uses its compiled-in default, which is system-dependent and almost certainly isn't where your web app is located. Thus, all requests, including for static files, go upstream to uWSGI.

To fix the problem, set a root directive pointing to your app's static resources.

server {
    root /srv/www/testapp;

Or if you only have static files in subdirectories, you can specify then with location and alias as shown in the uWSGI documentation.

location /static {
    alias /srv/www/testapp/static;
  • yup, added root to server description and all is well. Requests for static files are no longer showing up in uwsgi logs, only data routes that hit the python app are. Gracias.
    – reptilicus
    Jan 27, 2014 at 18:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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