Skip to content

Instantly share code, notes, and snippets.

@boogy
Forked from revolunet/nginx.conf
Created February 8, 2017 14:42
Show Gist options
  • Save boogy/b9d41415ad2336e7d1de1021f389a5ec to your computer and use it in GitHub Desktop.
Save boogy/b9d41415ad2336e7d1de1021f389a5ec to your computer and use it in GitHub Desktop.
Nginx, gunicorn + ssl (django)
upstream myapp_prod {
server unix:/home/apps/project/wsgi/gunicorn.sock fail_timeout=0;
}
server {
listen 80 default_server;
server_name .project.com;
return 301 https://www.project.com$request_uri;
}
server {
listen 443 default_server ssl;
server_name www.project.com;
ssl_certificate /home/apps/project/data/ssl/bundle.pem;
ssl_certificate_key /home/apps/project/data/ssl/private.pem;
ssl_prefer_server_ciphers On;
ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS;
client_max_body_size 10M;
access_log /home/apps/project/logs/nginx-access.log;
error_log /home/apps/project/logs/nginx-error.log;
error_page 500 501 502 503 504 /maintenance.html;
location /maintenance.html {
internal;
alias /home/apps/project/maintenance.html;
}
location /static/ {
alias /home/apps/project/static/;
access_log off;
gzip on;
gzip_min_length 1000;
gzip_types application/x-javascript text/css;
if ($request_filename ~* \.(ico|css|js|gif|jpe?g|png)$) {
expires 72h;
}
}
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
if (!-f $request_filename) {
proxy_pass http://myapp_prod;
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment