Last active
August 29, 2015 14:22
-
-
Save MattMS/b8e891ad751f0225213a to your computer and use it in GitHub Desktop.
Gunicorn configuration example.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Use this configuration with: | |
# cd /svr/flask | |
# ENV/bin/gunicorn -c gunicorn_conf.py manage:app | |
import multiprocessing | |
# http://docs.gunicorn.org/en/latest/configure.html#bind | |
# | |
bind = '127.0.0.1:8000' | |
# By preloading an application you can save some RAM resources as well | |
# as speed up server boot times. | |
# Although, if you defer application loading to each worker process, you | |
# can reload your application code easily by restarting workers. | |
# | |
# http://docs.gunicorn.org/en/latest/configure.html#preload-app | |
# | |
preload_app = False | |
# A positive integer generally in the 2-4 x $(NUM_CORES) range. | |
# You'll want to vary this a bit to find the best for your particular | |
# application's work load. | |
# | |
# http://docs.gunicorn.org/en/latest/configure.html#workers | |
# | |
workers = multiprocessing.cpu_count() * 2 + 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# To add the this configuration to the Nginx server: | |
# | |
# > ln -s /srv/flask/nginx.conf /etc/nginx/conf.d/my_site.conf | |
# > sudo service nginx -s reload | |
# | |
# You will need to reload Nginx each time you make changes to the | |
# configuration file. | |
# | |
server { | |
listen 80; | |
server_name _; | |
#server_name flask.example.com; | |
#access_log /var/log/nginx/access.log; | |
#error_log /var/log/nginx/error.log; | |
# Nginx is better at serving static files. | |
location /static/ { | |
alias /srv/flask/static/; | |
} | |
location / { | |
# This should match the IP and port that Gunicorn is running on | |
proxy_pass http://127.0.0.1:8000/; | |
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; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment