-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefault.conf.template
43 lines (36 loc) · 1.62 KB
/
default.conf.template
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
# Typically I use this file as a boilerplate to configure an nginx docker container
#
# This goes in /etc/nginx/conf.d/default.conf
# If you are reverse proxying an API
server {
listen 80; # SSL is not configured, but would be configured here
# If you are proxied, and the proxy doesn't support URL re-writing, A rewrite rule can be added here
# rewrite ^REWRITE_URL_GOES_HERE(.*)$ /$1;
location / {
root /usr/share/nginx/html;
# This is due to nginx and the try_files behavior below, it will always
# try to hit the index as part of try_files. If I set index as something
# that doesn't resolve, we don't have to worry about index.html being cached.
#
# If frequent updates occur, it's important that index.html not be cached
# in the browser. Otherwise the software update will only occur when the
# cached page expires. The If-Modified-Since is a better way to handle this
# for SPAs with frequent updates.
index unresolvable-file-html.html;
try_files $uri @index;
}
# This seperate location is so the no cache policy only applies to the index and nothing else.
location @index {
root /usr/share/nginx/html;
add_header Cache-Control no-cache;
expires 0;
try_files /index.html =404;
}
location /api/ {
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $http_host;
# If you have any long running API calls, the read timeout needs to be increased here
# proxy_read_timeout 120s;
proxy_pass http://${API_HOST}:${API_PORT}/api/;
}
}