This repository has been archived by the owner on Aug 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathnginx-site.conf
89 lines (73 loc) · 2.1 KB
/
nginx-site.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
# pushState friendly!
# The setup:
# * javascript app is located at `${APP_DIR}`
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;
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_DIR};
error_page 404 @rewrites;
# API Proxy
location ${APP_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 ${APP_API_GATEWAY}/;
}
# PREFIX PATH
location ${APP_PATH_PREFIX}/ {
rewrite ^${APP_PATH_PREFIX}/(.*) /$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"}';
}
# 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;
}