-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathnginx-site.conf
More file actions
130 lines (114 loc) · 3.65 KB
/
nginx-site.conf
File metadata and controls
130 lines (114 loc) · 3.65 KB
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# pushState friendly!
# The setup:
# * javascript app is located at `${APP_WORKDIR}`
charset utf-8;
gzip on;
tcp_nopush on;
tcp_nodelay off;
client_header_timeout ${CLIENT_HEADER_TIMEOUT}s;
client_body_timeout ${CLIENT_BODY_TIMEOUT}s;
client_max_body_size ${CLIENT_MAX_BODY_SIZE}k;
server_tokens off;
reset_timedout_connection on;
gzip_types
text/css
text/javascript
text/xml
text/plain
application/javascript
application/x-javascript
application/json
application/xml
application/rss+xml
application/atom+xml
font/truetype
font/opentype
image/svg+xml
image/png;
map $sent_http_content_type $expires {
default off;
text/html epoch;
/static/ 30d;
}
server {
listen 80;
root ${APP_WORKDIR};
error_page 404 @rewrites;
# API Proxy
location ${API_PLACEHOLDER}/ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-NginX-Proxy true;
proxy_set_header Connection "";
proxy_http_version 1.1;
proxy_pass ${API_GATEWAY}/;
}
location ${API_PLACEHOLDER_1}/ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-NginX-Proxy true;
proxy_set_header Connection "";
proxy_http_version 1.1;
proxy_pass ${API_GATEWAY_1}/;
}
location ${API_PLACEHOLDER_2}/ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-NginX-Proxy true;
proxy_set_header Connection "";
proxy_http_version 1.1;
proxy_pass ${API_GATEWAY_2}/;
}
location ${API_PLACEHOLDER_3}/ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-NginX-Proxy true;
proxy_set_header Connection "";
proxy_http_version 1.1;
proxy_pass ${API_GATEWAY_3}/;
}
location ${API_PLACEHOLDER_4}/ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-NginX-Proxy true;
proxy_set_header Connection "";
proxy_http_version 1.1;
proxy_pass ${API_GATEWAY_4}/;
}
location ${API_PLACEHOLDER_5}/ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-NginX-Proxy true;
proxy_set_header Connection "";
proxy_http_version 1.1;
proxy_pass ${API_GATEWAY_5}/;
}
# PREFIX PATH
location ${APP_BASENAME}/ {
rewrite ^${APP_BASENAME}/(.*) /$1 last;
}
# To make sure any assets can get through :)
location / {
try_files $uri $uri/ @rewrites;
# BEGIN_CONFIG_WHEN_WHITE_LIST_ON
if ($proxy_add_x_forwarded_for !~ "^${WHITE_LIST_IP}$") {
return 403;
}
# END_CONFIG_WHEN_WHITE_LIST_ON
}
location ~ ^/health {
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';
if ($request_method = 'OPTIONS') {
return 204;
}
default_type application/json;
return 200 '{"version":"${APP_VERSION}","status":"OK","build":"${BUILD}","debug":"${DEBUG}"}';
}
# If no asset matches, send it to your javascript app. Hopefully it's a route in the app!
location @rewrites {
rewrite ^(.+)$ /index.html last;
}
expires $expires;
}