Created
June 24, 2017 23:27
-
-
Save Jamp/23a3ba4a50533deda1bc5a3a6233ae71 to your computer and use it in GitHub Desktop.
Nginx for Django
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
upstream django_app_server { | |
server unix:/var/webapps/django/api.sock fail_timeout=0; | |
} | |
server { | |
listen 80; | |
server_name _; | |
client_max_body_size 4G; | |
access_log /var/webapps/django/logs/nginx-access.log; | |
error_log /var/webapps/django/logs/nginx-error.log; | |
location /static/ { | |
alias /var/webapps/django/static/; | |
} | |
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_app_server; | |
break; | |
} | |
} | |
error_page 404 /404.html; | |
location = /404.html { | |
root /var/webapps/django/static/; | |
} | |
error_page 500 502 503 504 /500.html; | |
location = /500.html { | |
root /var/webapps/django/static/; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment