-
Notifications
You must be signed in to change notification settings - Fork 0
/
nginx.conf
73 lines (57 loc) · 2.22 KB
/
nginx.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
daemon off;
worker_processes auto;
events {
worker_connections 1024;
}
error_log /dev/stdout warn;
pid /var/run/nginx.pid;
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '[$time_local] nginx $remote_addr - $remote_user "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" '
'$request_time $upstream_response_time $pipe';
access_log /dev/stdout main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
gzip on;
# the upstream component nginx needs to connect to
upstream django {
server unix:/app/app.sock; # for a file socket
}
# configuration of the server
server {
# the port your site will be served on, default_server indicates that this server block
# is the block to use if no blocks match the server_name
listen 8080 default_server;
# the domain name it will serve for
server_name .example.com; # substitute your machine's IP address or FQDN
charset utf-8;
# max upload size
client_max_body_size 75M; # adjust to taste
# Django media
location /media {
alias /app/media; # your Django project's media files - amend as required
}
location /static {
alias /app/staticfiles; # your Django project's static files - amend as required
}
set $my_host $host;
# if the host header is an ip address change it to healthcheck.fakenewslinks.com
# this works around requests coming from ELB with either the instance's
# internal ip address in the case of health checks or an unknown internal
# ip address in the case of latency checks. translating them to a known
# good host header makes django's ALLOWED_HOSTS happy
if ($host ~ "\d+\.\d+\.\d+\.\d+") {
set $my_host "healthcheck.fakenewslinks.com";
}
# Finally, send all non-media requests to the Django server.
location / {
uwsgi_pass django;
uwsgi_param HTTP_HOST $my_host;
include /app/uwsgi_params; # the uwsgi_params file you installed
}
}
}