forked from schleyfox/example-node-ops
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nginx.conf
102 lines (80 loc) · 2.39 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# Sample nginx config to run a server on localhost:9000 that proxies to an
# haproxy on localhost:9001. This is a heavily simplified version of what we
# run.
#
# Run with nginx -c nginx.conf -p ./
# Run a single worker process as that is sufficent to saturate our backend
worker_processes 1;
worker_rlimit_nofile 1048576;
pid logs/nginx.pid;
events {
worker_connections 768;
}
# settings necessary to run unprivileged in foreground
daemon off;
error_log logs/error.log;
http {
client_max_body_size 5M;
# settings necessary to run unprivileged in foreground
proxy_temp_path tmp/proxy;
client_body_temp_path tmp/body;
fastcgi_temp_path tmp/fastcgi;
uwsgi_temp_path tmp/uwsgi;
scgi_temp_path tmp/scgi;
access_log logs/access.log;
error_log logs/error.log;
proxy_read_timeout 600s;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
server_tokens off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
gzip on;
gzip_disable "msie6";
# relevant part of config
upstream example_app {
# our app listens on port 9001
server 127.0.0.1:9001 fail_timeout=0;
}
server {
# nginx listens on 9000
listen 9000 default_server;
# size of buffer for request body before spilling to disk.
# We've set this high as our renderer process large requests.
client_body_buffer_size 1m;
# absolute limit for client body size, analogous to body-parser's limit
client_max_body_size 5m;
# Response headers buffer size
proxy_buffer_size 8k;
# Response body buffers (1m)
proxy_buffers 8 128k;
# default route
location / {
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_redirect off;
proxy_pass http://example_app;
}
# special case for /health that proxies request with smaller buffers
location = /health {
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
# set smaller buffers for /health
client_body_buffer_size 8k;
proxy_buffers 8 8k;
proxy_redirect off;
proxy_pass http://example_app;
}
# offload /ping connectivity check so that it never hits the node app
location = /ping {
return 200 'PONG
';
}
}
}