Created
November 14, 2017 14:39
-
-
Save dpineiden/e6f8a717ee126d44e6c4c1d7e40bc327 to your computer and use it in GitHub Desktop.
nginx django channels
This file contains hidden or 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
# Enable upgrading of connection (and websocket proxying) depending on the | |
# presence of the upgrade field in the client request header | |
map $http_upgrade $connection_upgrade { | |
default upgrade; | |
'' close; | |
} | |
upstream wscada { | |
# fail_timeout=0 means we always retry an upstream even if it failed | |
# to return a good HTTP response (in case the Unicorn master nukes a | |
# single worker for timing out). | |
server 10.54.218.13:8004; | |
# unix:///tmp/wscada.sock; | |
} | |
server { | |
listen localhost:80; | |
listen 10.54.218.13:80; | |
server_name dpineda.csn.uchile.cl; | |
charset utf-8; | |
client_max_body_size 100M; | |
uwsgi_read_timeout 600; | |
proxy_read_timeout 60s; | |
#logs | |
access_log /home/dpineda/web/logs/access.log; | |
error_log /home/dpineda/web/logs/error.log; | |
# Django statics | |
location /static { | |
alias /home/dpineda/Proyectos/wscada/rtviz/files/static; # your Django project's static files - amend as required | |
} | |
location /media { | |
alias /home/dpineda/Proyectos/wscada/rtviz/files/media; # your Django project's st$ | |
} | |
location / { | |
# Pass request to the upstream alias | |
proxy_pass http://0.0.0.0:8004; | |
# Require http version 1.1 to allow for upgrade requests | |
proxy_http_version 1.1; | |
# We want proxy_buffering off for proxying to websockets. | |
proxy_buffering off; | |
# http://en.wikipedia.org/wiki/X-Forwarded-For | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
# enable this if you use HTTPS: | |
# proxy_set_header X-Forwarded-Proto https; | |
# pass the Host: header from the client for the sake of redirects | |
proxy_set_header Host $http_host; | |
# We've set the Host header, so we don't need Nginx to muddle | |
# about with redirects | |
proxy_redirect off; | |
# Depending on the request value, set the Upgrade and | |
# connection headers | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection $connection_upgrade; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment