serving files with flask and nginx/gunicorn

2

I have a basic website set up and I am running into some confusion on how to handle serving static files. I noticed the only thing I have to do to serve static files is set up the proxy to gunicorn in the nginx config.

location / {
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://127.0.0.1:8000;
        }

with just this and running my app though gunicorn gunicorn myapp:app I can serve static files from and only from the static folder directory. I am guessing this works because something from flask is saying serve all the files in this directory? (The development server isn't running either app.run() is commented out)

So my question is how do I stop nginx from serving these files automatically. I want to server them with my own location block for each type of file(videos, images, css/html/js, etc.). So they get served with the correct settings.

For clarification: website.com/static/css/test.css and website/css/test.css both serve the same file the first one is served automatically and the second one is the one I am serving with a location block

location /css/  {
        #other setting
        root  /home/app/static/;
}

I don't want website.com/static/css/test.css serving anything. I only want it to be served from the location block I defined.

user740721

Posted 2017-06-20T23:39:18.947

Reputation: 21

No answers