Nginx configuration for a Flask app with a uWSGI upstream
A sample Nginx server block configuration to deploy a <a href="https://lemp.io/qa/question/deploying-flask-applications-on-lemp/">Flask application</a> using uWSGI. Uses Nginx's <a href="http://nginx.org/en/docs/http/ngx_http_upstream_module.html">upstream directive</a> and supports <a href="http://nginx.org/en/docs/http/ngx_http_core_module.html#listen">IPv6</a>.
upstream uwsgi_host {
server unix:/tmp/flaskapp.sock;
}
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
location ^~ /static/ {
alias /srv/www/flaskapp/app/static;
}
location / { try_files $uri @flaskapp; }
location @flaskapp {
include uwsgi_params;
uwsgi_pass uwsgi_host;
}
}
Written by James Bradach
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Nginx
Authors
reiaguilera
279.6K
jamesdullaghan
90.19K
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#