Skip to content

Instantly share code, notes, and snippets.

@AzMoo
Created April 29, 2016 04:51
Show Gist options
  • Save AzMoo/c854aae3e6abb1535572290ca2a2a229 to your computer and use it in GitHub Desktop.
Save AzMoo/c854aae3e6abb1535572290ca2a2a229 to your computer and use it in GitHub Desktop.
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
events {
worker_connections 1024;
}
http {
log_format main '\$remote_addr - \$remote_user [\$time_local] "\$request" '
'\$status \$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 on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
map \$http_upgrade \$connection_upgrade {
default upgrade;
'' close;
}
upstream django_server {
server 127.0.0.1:8000;
}
upstream websocket_server {
server 127.0.0.1:8080;
}
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
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://django_server;
break;
}
}
location /ws {
proxy_pass http://websocket_server;
proxy_http_version 1.1;
proxy_set_header Upgrade \$http_upgrade;
proxy_set_header Connection \$connection_upgrade;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
proxy_intercept_errors on;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment