Skip to content

Instantly share code, notes, and snippets.

@digital-shokunin
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save digital-shokunin/226f9cd8b4f430eedfeb to your computer and use it in GitHub Desktop.
Save digital-shokunin/226f9cd8b4f430eedfeb to your computer and use it in GitHub Desktop.
Nginx & uWSGI config files for flask site
upstream uwsgicluster {
#keepalive 128;
#server 127.0.0.1:8080;
server unix:/run/uwsgi/webapps/flask-example/socket;
}
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /usr/share/nginx/html;
index index.html index.htm;
# Make site accessible from http://localhost/
server_name localhost;
# Settings to by-pass for static files
location ^~ /static/ {
# Example:
# root /full/path/to/application/static/file/dir;
root /webapps/static/;
}
# Serve a static file (ex. favico) outside static dir.
location = /favico.ico {
root /webapps/static/favico.ico;
}
# Proxying connections to application servers
location / {
include uwsgi_params;
uwsgi_pass uwsgicluster;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
}
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
[uwsgi]
chdir=/webapps/flask-example
file = app.py
pp=/webapps/flask-example
module=app
callable=app
plugins=python
chown-socket=www-data
vacuum=true
die-on-term=true
limit-as=512
touch-reload=/webapps/reload
#Below are optional settings if not provided by default install
# enable master process manager
#master = true
# spawn 2 uWSGI worker processes
#workers = 4
# automatically kill workers on master's death
#no-orphans = true
# write master's pid in file /run/uwsgi/<confnamespace>/<confname>/pid
#pidfile = /run/uwsgi/%(deb-confnamespace)/%(deb-confname)/pid
#pidfile2 = /tmp/%(deb-confname).pid
# bind to UNIX socket at /run/uwsgi/<confnamespace>/<confname>/socket
#socket = /run/uwsgi/%(deb-confnamespace)/%(deb-confname)/socket
# set mode of created UNIX socket
#chmod-socket = 665
# place timestamps into log
#log-date = true
# user identifier of uWSGI processes
#uid = www-data
# group identifier of uWSGI processes
#gid = www-data
# enable threads
#enable-threads = true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment