Created
December 13, 2016 11:09
-
-
Save aalhour/06846bb2b30d0c8637195b2465a3f7a9 to your computer and use it in GitHub Desktop.
Configuration Files for Nginx + Gunicorn + Supervisord (See original: https://gist.github.com/dstufft/997475)
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
bind = "127.0.0.1:9006" | |
workers = 2 | |
worker_class = 'gevent' | |
max_requests = 1000 | |
timeout = 30 | |
keep_alive = 2 | |
preload = True |
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
user www-data; | |
worker_processes 4; | |
error_log /var/log/nginx/error.log; | |
pid /var/run/nginx.pid; | |
events { | |
worker_connections 1024; | |
accept_mutex off; | |
use epoll; | |
} | |
http { | |
include mime.types; | |
default_type application/octet-stream; | |
log_format main '$remote_addr - $remote_user [$time_local] $status ' | |
'"$request" $body_bytes_sent "$http_referer" ' | |
'"$http_user_agent" "$http_x_forwarded_for"'; | |
access_log /var/log/nginx/access.log main; | |
sendfile on; | |
tcp_nopush on; | |
tcp_nodelay off; | |
keepalive_timeout 5; | |
client_max_body_size 5M; | |
gzip on; | |
gzip_http_version 1.0; | |
gzip_comp_level 9; | |
#gzip_min_length 1100; | |
gzip_buffers 4 8k; | |
gzip_proxied any; | |
gzip_types | |
text/plain | |
text/xml | |
application/xml | |
application/xml+rss | |
text/css | |
text/javascript | |
application/javascript | |
application/x-javascript | |
application/json; | |
gzip_static on; | |
gzip_proxied | |
expired | |
no-cache | |
no-store | |
private | |
auth; | |
gzip_disable "MSIE [1-6]\."; | |
gzip_vary on; | |
include /etc/nginx/conf.d/*.conf; | |
include /etc/nginx/sites-enabled/*; | |
} |
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
server { | |
listen 80; | |
server_name www.example.com; | |
rewrite ^(.*) http://example.com$1 permanent; | |
} | |
server { | |
listen 80; | |
server_name example.com; | |
access_log /var/log/nginx/example.com.access.log main; | |
root /home/example/projects/example; | |
location / { | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header Host $http_host; | |
proxy_redirect off; | |
proxy_pass http://127.0.0.1:9006; | |
} | |
location /static/ { | |
alias /home/example/projects/evilgenius/site_media/static/; | |
expires 90d; | |
} | |
location /media/ { | |
alias /home/example/projects/evilgenius/site_media/media/; | |
expires 90d; | |
} | |
} |
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
[program:example.gunicorn] | |
process_name=example.gunicorn | |
command=/home/example/.virtualenvs/example/bin/gunicorn_django -c /home/example/projects/example/deploy/gunicorn.conf.py /home/example/projects/example/settings.py | |
directory=/home/example/projects/example | |
user=example | |
autostart=true | |
autorestart=true |
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
; supervisor config file | |
[unix_http_server] | |
file=/var/run/supervisor.sock ; (the path to the socket file) | |
chmod=0770 ; sockef file mode (default 0700) | |
chown=nobody:supervisord | |
[supervisord] | |
logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log) | |
pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid) | |
childlogdir=/var/log/supervisor ; ('AUTO' child log dir, default $TEMP) | |
; the below section must remain in the config file for RPC | |
; (supervisorctl/web interface) to work, additional interfaces may be | |
; added by defining them in separate rpcinterface: sections | |
[rpcinterface:supervisor] | |
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface | |
[supervisorctl] | |
serverurl=unix:///var/run/supervisor.sock ; use a unix:// URL for a unix socket | |
; The [include] section can just contain the "files" setting. This | |
; setting can list multiple files (separated by whitespace or | |
; newlines). It can also contain wildcards. The filenames are | |
; interpreted as relative to this file. Included files *cannot* | |
; include files themselves. | |
[include] | |
files = /etc/supervisor/conf.d/*.conf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment