Skip to content

Instantly share code, notes, and snippets.

@dvl
Last active September 8, 2016 16:38
Show Gist options
  • Save dvl/7528434 to your computer and use it in GitHub Desktop.
Save dvl/7528434 to your computer and use it in GitHub Desktop.
worker_processes auto;
worker_rlimit_nofile 8192;
user nginx;
pid /var/run/nginx.pid;
# error_log /var/log/nginx/error.log warn;
events {
worker_connections 2048;
multi_accept on;
use epoll;
accept_mutex off;
}
http {
include mime.types;
# default_type application/octet-stream;
default_type text/html;
charset UTF-8;
# access_log /var/log/nginx/access.log combined;
access_log off;
error_log /var/log/nginx/error.log crit;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 20;
client_header_timeout 20;
client_body_timeout 20;
reset_timedout_connection on;
send_timeout 20;
limit_conn_zone $binary_remote_addr zone=addr:5m;
limit_conn addr 100;
gzip on;
# gzip_static on;
gzip_proxied any;
gzip_min_length 256;
gzip_comp_level 4;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
open_file_cache max=100000 inactive=20s;
open_file_cache_valid 30s;
open_file_cache_min_uses 2;
open_file_cache_errors on;
## Sites
# include /etc/nginx/conf.d/*.conf;
upstream app_server {
# server unix:/tmp/gunicorn.sock fail_timeout=0;
# For a TCP configuration:
server 127.0.0.1:9000 fail_timeout=0;
}
server {
listen 80 default;
client_max_body_size 4G;
server_name _;
keepalive_timeout 5;
# path for static files
# only use if your static dir is not in same folder as django
# otherwise comment this line and uncomment the blocks above
root /usr/share/nginx/html;
# location /static/ {
# alias /var/www/django/static/;
# expires 30d;
#}
#location /media/ {
# alias /home/www/django/media/;
# expires 30d;
#}
location / {
# checks for static file, if not found proxy to app
try_files $uri @proxy_to_app;
}
location @proxy_to_app {
proxy_pass http://app_server;
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-Proto $scheme;
}
error_page 500 502 503 504 /50x.html;
location = /500.html {
root /usr/share/nginx/html;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment