This repository has been archived by the owner on Nov 30, 2021. It is now read-only.
/
nginx.conf
136 lines (113 loc) · 4.29 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
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
131
132
133
134
135
136
# required to run in a container
daemon off;
user www-data;
worker_processes 4;
pid /run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
# basic settings
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
server_names_hash_bucket_size 64;
include /opt/nginx/conf/mime.types;
default_type application/octet-stream;
{{ if .deis_router_gzip }}
gzip {{ .deis_router_gzip }};
gzip_comp_level {{ .deis_router_gzipCompLevel }};
gzip_disable {{ .deis_router_gzipDisable }};
gzip_http_version {{ .deis_router_gzipHttpVersion }};
gzip_types {{ .deis_router_gzipTypes }};
gzip_proxied {{ .deis_router_gzipProxied }};
gzip_vary {{ .deis_router_gzipVary }};{{ end }}
client_max_body_size {{ or (.deis_router_bodySize) "1m" }};
# send logs to STDOUT so they can be seen using 'docker logs'
access_log /dev/stdout;
error_log /dev/stdout;
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
## start deis-controller
{{ if .deis_controller_host }}
upstream deis-controller {
server {{ .deis_controller_host }}:{{ .deis_controller_port }};
}
server {
server_name ~^deis\.(?<domain>.+)$;
server_name_in_redirect off;
port_in_redirect off;
location / {
proxy_buffering off;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_redirect off;
proxy_connect_timeout {{ or (.deis_router_controller_timeout_connect) "10s" }};
proxy_send_timeout {{ or (.deis_router_controller_timeout_send) "20m" }};
proxy_read_timeout {{ or (.deis_router_controller_timeout_read) "20m" }};
proxy_pass http://deis-controller;
}
}{{ end }}
## end deis-controller
## start service definitions for each application
{{ $domains := .deis_domains }}{{ range $service := .deis_services }}{{ if $service.Nodes }}
upstream {{ Base $service.Key }} {
{{ range $upstream := $service.Nodes }}server {{ $upstream.Value }};
{{ end }}
}
server {
server_name ~^{{ Base $service.Key }}\.(?<domain>.+)${{ range $app_domains := $domains }}{{ if eq (Base $service.Key) (Base $app_domains.Key) }} {{ $app_domains.Value }}{{ end }}{{ end }};
server_name_in_redirect off;
port_in_redirect off;
location / {
proxy_buffering off;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_redirect off;
proxy_connect_timeout 10s;
proxy_send_timeout 1200s;
proxy_read_timeout 1200s;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_next_upstream error timeout http_502 http_503 http_504;
add_header X-Deis-Upstream $upstream_addr;
proxy_pass http://{{ Base $service.Key }};
}
}
{{ end }}{{ end }}
## end service definitions for each application
# healthcheck
server {
listen 80 default_server;
location /health-check {
default_type 'text/plain';
access_log off;
return 200;
}
}
}
## start builder
{{ if .deis_builder_host }}
tcp {
access_log /dev/stdout;
tcp_nodelay on;
timeout {{ or (.deis_router_builder_timeout_tcp) "1200000" }};
# same directive names, but these are in miliseconds...
proxy_connect_timeout {{ or (.deis_router_builder_timeout_connect) "10000" }};
proxy_send_timeout {{ or (.deis_router_builder_timeout_send) "1200000" }};
proxy_read_timeout {{ or (.deis_router_builder_timeout_read) "1200000" }};
upstream builder {
server {{ .deis_builder_host }}:{{ .deis_builder_port }};
}
server {
listen 2222;
proxy_pass builder;
}
}{{ end }}
## end builder