-
Notifications
You must be signed in to change notification settings - Fork 0
/
nginx.proxy.conf.esh
95 lines (73 loc) · 3.01 KB
/
nginx.proxy.conf.esh
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
<%
PROXY_URL="${PROXY_URL:-missing}"
PROXY_HOST="${PROXY_HOST:-${PROXY_URL}}"
MAIN_CACHE="${MAIN_CACHE:-false}"
MAIN_CACHE_QUERY="${MAIN_CACHE_QUERY:-false}"
SECONDARY_REGEX="${SECONDARY_REGEX:-false}"
SECONDARY_CACHE="${SECONDARY_CACHE:-false}"
SECONDARY_CACHE_QUERY="${SECONDARY_CACHE_QUERY:-false}"
CACHE_VALIDITY_DURATION="${CACHE_VALIDITY_DURATION:-1h}"
-%>
proxy_cache_path /tmp/proxy-cache levels=1:2 keys_zone=default_cache:10m max_size=1g
inactive=1d use_temp_path=off;
server {
resolver 1.1.1.1;
listen 80;
location /healthz {
access_log off;
add_header Content-Type text/plain;
return 200 "OK\n";
}
set $proxy_url <%= $PROXY_URL %>;
<% if test "$SECONDARY_REGEX" != "false"; then %>
location <%= $SECONDARY_REGEX %> {
access_log /var/log/nginx/access.log proxy_logging;
proxy_set_header Host <%= $PROXY_HOST %>;
proxy_pass https://$proxy_url;
proxy_ssl_server_name on;
proxy_redirect http://$proxy_url/ /;
proxy_redirect https://$proxy_url/ /;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwared-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
<% if test "$SECONDARY_CACHE" = "true"; then %>
proxy_ignore_headers Cache-Control Set-Cookie;
proxy_cache_valid 500 502 503 504 1m;
proxy_cache_valid any <%= $CACHE_VALIDITY_DURATION %>;
# See https://www.nginx.com/blog/nginx-caching-guide/
proxy_cache default_cache;
proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
proxy_cache_background_update on;
proxy_cache_lock on;
<% if test "$SECONDARY_CACHE_QUERY" = "true"; then %>
proxy_cache_key "$scheme$host$uri";
<% fi %>
<% fi %>
}
<% fi %>
location / {
access_log /var/log/nginx/access.log proxy_logging;
proxy_set_header Host <%= $PROXY_HOST %>;
proxy_pass https://$proxy_url;
proxy_ssl_server_name on;
proxy_redirect http://$proxy_url/ /;
proxy_redirect https://$proxy_url/ /;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwared-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
<% if test "$MAIN_CACHE" = "true"; then %>
proxy_ignore_headers Cache-Control Set-Cookie;
proxy_cache_valid 500 502 503 504 1m;
proxy_cache_valid any <%= $CACHE_VALIDITY_DURATION %>;
# See https://www.nginx.com/blog/nginx-caching-guide/
proxy_cache default_cache;
proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
proxy_cache_background_update on;
proxy_cache_lock on;
<% if test "$MAIN_CACHE_QUERY" = "true"; then %>
proxy_cache_key "$scheme$host$uri";
<% fi %>
<% fi %>
}
include /etc/nginx/extra-conf.d/*.conf;
}