-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update nginx conf based on gunicorn docs
- Loading branch information
Showing
1 changed file
with
47 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,55 @@ | ||
upstream django { | ||
server django:8000; | ||
worker_processes 1; | ||
|
||
events { | ||
worker_connections 1024; # increase if you have lots of clients | ||
accept_mutex off; # set to 'on' if nginx worker_processes > 1 | ||
# 'use epoll;' to enable for Linux 2.6+ | ||
# 'use kqueue;' to enable for FreeBSD, OSX | ||
} | ||
|
||
server { | ||
http { | ||
include mime.types; | ||
# fallback in case we can't determine a type | ||
default_type application/octet-stream; | ||
access_log /var/log/nginx/access.log combined; | ||
sendfile on; | ||
|
||
upstream app_server { | ||
# fail_timeout=0 means we always retry an upstream even if it failed | ||
# to return a good HTTP response | ||
|
||
# for UNIX domain socket setups | ||
# server unix:/tmp/gunicorn.sock fail_timeout=0; | ||
|
||
# for a TCP configuration | ||
server django:8000 fail_timeout=0; | ||
} | ||
|
||
server { | ||
# if no Host match, close the connection to prevent host spoofing | ||
listen 80 default_server; | ||
return 444; | ||
} | ||
|
||
server { | ||
# use 'listen 80 deferred;' for Linux | ||
# use 'listen 80 accept_filter=httpready;' for FreeBSD | ||
listen 80; | ||
client_max_body_size 4G; | ||
|
||
# set the correct host(s) for your site | ||
server_name 34.82.120.199; | ||
|
||
keepalive_timeout 5; | ||
|
||
location / { | ||
proxy_pass http://django; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header Host $host; | ||
proxy_redirect off; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header X-Forwarded-Proto $scheme; | ||
proxy_set_header Host $http_host; | ||
# we don't want nginx trying to do something clever with | ||
# redirects, we set the Host: header above already. | ||
proxy_redirect off; | ||
proxy_pass http://app_server; | ||
} | ||
|
||
} | ||
} |