nginx.tmpl 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  1. {{ $CurrentContainer := where $ "ID" .Docker.CurrentContainerID | first }}
  2. {{ define "upstream" }}
  3. {{ if .Address }}
  4. {{/* If we got the containers from swarm and this container's port is published to host, use host IP:PORT */}}
  5. {{ if and .Container.Node.ID .Address.HostPort }}
  6. # {{ .Container.Node.Name }}/{{ .Container.Name }}
  7. server {{ .Container.Node.Address.IP }}:{{ .Address.HostPort }};
  8. {{/* If there is no swarm node or the port is not published on host, use container's IP:PORT */}}
  9. {{ else if .Network }}
  10. # {{ .Container.Name }}
  11. server {{ .Network.IP }}:{{ .Address.Port }};
  12. {{ end }}
  13. {{ else if .Network }}
  14. # {{ .Container.Name }}
  15. {{ if .Network.IP }}
  16. server {{ .Network.IP }} down;
  17. {{ else }}
  18. server 127.0.0.1 down;
  19. {{ end }}
  20. {{ end }}
  21. {{ end }}
  22. {{ define "ssl_policy" }}
  23. {{ if eq .ssl_policy "Mozilla-Modern" }}
  24. ssl_protocols TLSv1.3;
  25. {{/* nginx currently lacks ability to choose ciphers in TLS 1.3 in configuration, see https://trac.nginx.org/nginx/ticket/1529 /*}}
  26. {{/* a possible workaround can be modify /etc/ssl/openssl.cnf to change it globally (see https://trac.nginx.org/nginx/ticket/1529#comment:12 ) /*}}
  27. {{/* explicitly set ngnix default value in order to allow single servers to override the global http value */}}
  28. ssl_ciphers HIGH:!aNULL:!MD5;
  29. ssl_prefer_server_ciphers off;
  30. {{ else if eq .ssl_policy "Mozilla-Intermediate" }}
  31. ssl_protocols TLSv1.2 TLSv1.3;
  32. ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384';
  33. ssl_prefer_server_ciphers off;
  34. {{ else if eq .ssl_policy "Mozilla-Old" }}
  35. ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
  36. ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA256:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA';
  37. ssl_prefer_server_ciphers on;
  38. {{ else if eq .ssl_policy "AWS-TLS-1-2-2017-01" }}
  39. ssl_protocols TLSv1.2 TLSv1.3;
  40. ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:AES128-GCM-SHA256:AES128-SHA256:AES256-GCM-SHA384:AES256-SHA256';
  41. ssl_prefer_server_ciphers on;
  42. {{ else if eq .ssl_policy "AWS-TLS-1-1-2017-01" }}
  43. ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
  44. ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:AES128-GCM-SHA256:AES128-SHA256:AES128-SHA:AES256-GCM-SHA384:AES256-SHA256:AES256-SHA';
  45. ssl_prefer_server_ciphers on;
  46. {{ else if eq .ssl_policy "AWS-2016-08" }}
  47. ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
  48. ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:AES128-GCM-SHA256:AES128-SHA256:AES128-SHA:AES256-GCM-SHA384:AES256-SHA256:AES256-SHA';
  49. ssl_prefer_server_ciphers on;
  50. {{ else if eq .ssl_policy "AWS-2015-05" }}
  51. ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
  52. ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:AES128-GCM-SHA256:AES128-SHA256:AES128-SHA:AES256-GCM-SHA384:AES256-SHA256:AES256-SHA:DES-CBC3-SHA';
  53. ssl_prefer_server_ciphers on;
  54. {{ else if eq .ssl_policy "AWS-2015-03" }}
  55. ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
  56. ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:AES128-GCM-SHA256:AES128-SHA256:AES128-SHA:AES256-GCM-SHA384:AES256-SHA256:AES256-SHA:DHE-DSS-AES128-SHA:DES-CBC3-SHA';
  57. ssl_prefer_server_ciphers on;
  58. {{ else if eq .ssl_policy "AWS-2015-02" }}
  59. ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
  60. ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:AES128-GCM-SHA256:AES128-SHA256:AES128-SHA:AES256-GCM-SHA384:AES256-SHA256:AES256-SHA:DHE-DSS-AES128-SHA';
  61. ssl_prefer_server_ciphers on;
  62. {{ end }}
  63. {{ end }}
  64. # If we receive X-Forwarded-Proto, pass it through; otherwise, pass along the
  65. # scheme used to connect to this server
  66. map $http_x_forwarded_proto $proxy_x_forwarded_proto {
  67. default $http_x_forwarded_proto;
  68. '' $scheme;
  69. }
  70. # If we receive X-Forwarded-Port, pass it through; otherwise, pass along the
  71. # server port the client connected to
  72. map $http_x_forwarded_port $proxy_x_forwarded_port {
  73. default $http_x_forwarded_port;
  74. '' $server_port;
  75. }
  76. # If we receive Upgrade, set Connection to "upgrade"; otherwise, delete any
  77. # Connection header that may have been passed to this server
  78. map $http_upgrade $proxy_connection {
  79. default upgrade;
  80. '' close;
  81. }
  82. # Apply fix for very long server names
  83. server_names_hash_bucket_size 128;
  84. # Default dhparam
  85. {{ if (exists "/etc/nginx/dhparam/dhparam.pem") }}
  86. ssl_dhparam /etc/nginx/dhparam/dhparam.pem;
  87. {{ end }}
  88. # Set appropriate X-Forwarded-Ssl header
  89. map $scheme $proxy_x_forwarded_ssl {
  90. default off;
  91. https on;
  92. }
  93. gzip_types text/plain text/css application/javascript application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
  94. log_format vhost '$host $remote_addr - $remote_user [$time_local] '
  95. '"$request" $status $body_bytes_sent '
  96. '"$http_referer" "$http_user_agent"';
  97. access_log off;
  98. {{/* Get the SSL_POLICY defined by this container, falling back to "Mozilla-Intermediate" */}}
  99. {{ $ssl_policy := or ($.Env.SSL_POLICY) "Mozilla-Intermediate" }}
  100. {{ template "ssl_policy" (dict "ssl_policy" $ssl_policy) }}
  101. {{ if $.Env.RESOLVERS }}
  102. resolver {{ $.Env.RESOLVERS }};
  103. {{ end }}
  104. {{ if (exists "/etc/nginx/proxy.conf") }}
  105. include /etc/nginx/proxy.conf;
  106. {{ else }}
  107. # HTTP 1.1 support
  108. proxy_http_version 1.1;
  109. proxy_buffering off;
  110. proxy_set_header Host $http_host;
  111. proxy_set_header Upgrade $http_upgrade;
  112. proxy_set_header Connection $proxy_connection;
  113. proxy_set_header X-Real-IP $remote_addr;
  114. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  115. proxy_set_header X-Forwarded-Proto $proxy_x_forwarded_proto;
  116. proxy_set_header X-Forwarded-Ssl $proxy_x_forwarded_ssl;
  117. proxy_set_header X-Forwarded-Port $proxy_x_forwarded_port;
  118. # Mitigate httpoxy attack (see README for details)
  119. proxy_set_header Proxy "";
  120. {{ end }}
  121. {{ $enable_ipv6 := eq (or ($.Env.ENABLE_IPV6) "") "true" }}
  122. server {
  123. server_name _; # This is just an invalid value which will never trigger on a real hostname.
  124. listen 80;
  125. {{ if $enable_ipv6 }}
  126. listen [::]:80;
  127. {{ end }}
  128. access_log /var/log/nginx/access.log vhost;
  129. return 503;
  130. }
  131. {{ if (and (exists "/etc/nginx/certs/default.crt") (exists "/etc/nginx/certs/default.key")) }}
  132. server {
  133. server_name _; # This is just an invalid value which will never trigger on a real hostname.
  134. listen 443 ssl http2;
  135. {{ if $enable_ipv6 }}
  136. listen [::]:443 ssl http2;
  137. {{ end }}
  138. access_log /var/log/nginx/access.log vhost;
  139. return 503;
  140. ssl_session_cache shared:SSL:50m;
  141. ssl_session_tickets off;
  142. ssl_certificate /etc/nginx/certs/default.crt;
  143. ssl_certificate_key /etc/nginx/certs/default.key;
  144. }
  145. {{ end }}
  146. {{ range $host, $containers := groupByMulti $ "Env.VIRTUAL_HOST" "," }}
  147. {{ $host := trim $host }}
  148. {{ $is_regexp := hasPrefix "~" $host }}
  149. {{ $upstream_name := when $is_regexp (sha1 $host) $host }}
  150. # {{ $host }}
  151. upstream {{ $upstream_name }} {
  152. {{ range $container := $containers }}
  153. {{ $addrLen := len $container.Addresses }}
  154. {{ range $knownNetwork := $CurrentContainer.Networks }}
  155. {{ range $containerNetwork := $container.Networks }}
  156. {{ if (and (ne $containerNetwork.Name "ingress") (or (eq $knownNetwork.Name $containerNetwork.Name) (eq $knownNetwork.Name "host"))) }}
  157. ## Can be connected with "{{ $containerNetwork.Name }}" network
  158. {{/* If only 1 port exposed, use that */}}
  159. {{ if eq $addrLen 1 }}
  160. {{ $address := index $container.Addresses 0 }}
  161. {{ template "upstream" (dict "Container" $container "Address" $address "Network" $containerNetwork) }}
  162. {{/* If more than one port exposed, use the one matching VIRTUAL_PORT env var, falling back to standard web port 80 */}}
  163. {{ else }}
  164. {{ $port := coalesce $container.Env.VIRTUAL_PORT "80" }}
  165. {{ $address := where $container.Addresses "Port" $port | first }}
  166. {{ template "upstream" (dict "Container" $container "Address" $address "Network" $containerNetwork) }}
  167. {{ end }}
  168. {{ else }}
  169. # Cannot connect to network of this container
  170. server 127.0.0.1 down;
  171. {{ end }}
  172. {{ end }}
  173. {{ end }}
  174. {{ end }}
  175. }
  176. {{ $default_host := or ($.Env.DEFAULT_HOST) "" }}
  177. {{ $default_server := index (dict $host "" $default_host "default_server") $host }}
  178. {{/* Get the VIRTUAL_PROTO defined by containers w/ the same vhost, falling back to "http" */}}
  179. {{ $proto := trim (or (first (groupByKeys $containers "Env.VIRTUAL_PROTO")) "http") }}
  180. {{/* Get the NETWORK_ACCESS defined by containers w/ the same vhost, falling back to "external" */}}
  181. {{ $network_tag := or (first (groupByKeys $containers "Env.NETWORK_ACCESS")) "external" }}
  182. {{/* Get the HTTPS_METHOD defined by containers w/ the same vhost, falling back to "redirect" */}}
  183. {{ $https_method := or (first (groupByKeys $containers "Env.HTTPS_METHOD")) "redirect" }}
  184. {{/* Get the SSL_POLICY defined by containers w/ the same vhost, falling back to empty string (use default) */}}
  185. {{ $ssl_policy := or (first (groupByKeys $containers "Env.SSL_POLICY")) "" }}
  186. {{/* Get the HSTS defined by containers w/ the same vhost, falling back to "max-age=31536000" */}}
  187. {{ $hsts := or (first (groupByKeys $containers "Env.HSTS")) "max-age=31536000" }}
  188. {{/* Get the VIRTUAL_ROOT By containers w/ use fastcgi root */}}
  189. {{ $vhost_root := or (first (groupByKeys $containers "Env.VIRTUAL_ROOT")) "/var/www/public" }}
  190. {{/* Get the first cert name defined by containers w/ the same vhost */}}
  191. {{ $certName := (first (groupByKeys $containers "Env.CERT_NAME")) }}
  192. {{/* Get the best matching cert by name for the vhost. */}}
  193. {{ $vhostCert := (closest (dir "/etc/nginx/certs") (printf "%s.crt" $host))}}
  194. {{/* vhostCert is actually a filename so remove any suffixes since they are added later */}}
  195. {{ $vhostCert := trimSuffix ".crt" $vhostCert }}
  196. {{ $vhostCert := trimSuffix ".key" $vhostCert }}
  197. {{/* Use the cert specified on the container or fallback to the best vhost match */}}
  198. {{ $cert := (coalesce $certName $vhostCert) }}
  199. {{ $is_https := (and (ne $https_method "nohttps") (ne $cert "") (exists (printf "/etc/nginx/certs/%s.crt" $cert)) (exists (printf "/etc/nginx/certs/%s.key" $cert))) }}
  200. {{ if $is_https }}
  201. {{ if eq $https_method "redirect" }}
  202. server {
  203. server_name {{ $host }};
  204. listen 80 {{ $default_server }};
  205. {{ if $enable_ipv6 }}
  206. listen [::]:80 {{ $default_server }};
  207. {{ end }}
  208. access_log /var/log/nginx/access.log vhost;
  209. return 301 https://$host$request_uri;
  210. }
  211. {{ end }}
  212. server {
  213. server_name {{ $host }};
  214. listen 443 ssl http2 {{ $default_server }};
  215. {{ if $enable_ipv6 }}
  216. listen [::]:443 ssl http2 {{ $default_server }};
  217. {{ end }}
  218. access_log /var/log/nginx/access.log vhost;
  219. {{ if eq $network_tag "internal" }}
  220. # Only allow traffic from internal clients
  221. include /etc/nginx/network_internal.conf;
  222. {{ end }}
  223. {{ template "ssl_policy" (dict "ssl_policy" $ssl_policy) }}
  224. ssl_session_timeout 5m;
  225. ssl_session_cache shared:SSL:50m;
  226. ssl_session_tickets off;
  227. ssl_certificate /etc/nginx/certs/{{ (printf "%s.crt" $cert) }};
  228. ssl_certificate_key /etc/nginx/certs/{{ (printf "%s.key" $cert) }};
  229. {{ if (exists (printf "/etc/nginx/certs/%s.dhparam.pem" $cert)) }}
  230. ssl_dhparam {{ printf "/etc/nginx/certs/%s.dhparam.pem" $cert }};
  231. {{ end }}
  232. {{ if (exists (printf "/etc/nginx/certs/%s.chain.pem" $cert)) }}
  233. ssl_stapling on;
  234. ssl_stapling_verify on;
  235. ssl_trusted_certificate {{ printf "/etc/nginx/certs/%s.chain.pem" $cert }};
  236. {{ end }}
  237. {{ if (not (or (eq $https_method "noredirect") (eq $hsts "off"))) }}
  238. add_header Strict-Transport-Security "{{ trim $hsts }}" always;
  239. {{ end }}
  240. {{ if (exists (printf "/etc/nginx/vhost.d/%s" $host)) }}
  241. include {{ printf "/etc/nginx/vhost.d/%s" $host }};
  242. {{ else if (exists "/etc/nginx/vhost.d/default") }}
  243. include /etc/nginx/vhost.d/default;
  244. {{ end }}
  245. location / {
  246. {{ if eq $proto "uwsgi" }}
  247. include uwsgi_params;
  248. uwsgi_pass {{ trim $proto }}://{{ trim $upstream_name }};
  249. {{ else if eq $proto "fastcgi" }}
  250. root {{ trim $vhost_root }};
  251. include fastcgi_params;
  252. fastcgi_pass {{ trim $upstream_name }};
  253. {{ else }}
  254. proxy_pass {{ trim $proto }}://{{ trim $upstream_name }};
  255. {{ end }}
  256. {{ if (exists (printf "/etc/nginx/htpasswd/%s" $host)) }}
  257. auth_basic "Restricted {{ $host }}";
  258. auth_basic_user_file {{ (printf "/etc/nginx/htpasswd/%s" $host) }};
  259. {{ end }}
  260. {{ if (exists (printf "/etc/nginx/vhost.d/%s_location" $host)) }}
  261. include {{ printf "/etc/nginx/vhost.d/%s_location" $host}};
  262. {{ else if (exists "/etc/nginx/vhost.d/default_location") }}
  263. include /etc/nginx/vhost.d/default_location;
  264. {{ end }}
  265. }
  266. }
  267. {{ end }}
  268. {{ if or (not $is_https) (eq $https_method "noredirect") }}
  269. server {
  270. server_name {{ $host }};
  271. listen 80 {{ $default_server }};
  272. {{ if $enable_ipv6 }}
  273. listen [::]:80 {{ $default_server }};
  274. {{ end }}
  275. access_log /var/log/nginx/access.log vhost;
  276. {{ if eq $network_tag "internal" }}
  277. # Only allow traffic from internal clients
  278. include /etc/nginx/network_internal.conf;
  279. {{ end }}
  280. {{ if (exists (printf "/etc/nginx/vhost.d/%s" $host)) }}
  281. include {{ printf "/etc/nginx/vhost.d/%s" $host }};
  282. {{ else if (exists "/etc/nginx/vhost.d/default") }}
  283. include /etc/nginx/vhost.d/default;
  284. {{ end }}
  285. location / {
  286. {{ if eq $proto "uwsgi" }}
  287. include uwsgi_params;
  288. uwsgi_pass {{ trim $proto }}://{{ trim $upstream_name }};
  289. {{ else if eq $proto "fastcgi" }}
  290. root {{ trim $vhost_root }};
  291. include fastcgi_params;
  292. fastcgi_pass {{ trim $upstream_name }};
  293. {{ else }}
  294. proxy_pass {{ trim $proto }}://{{ trim $upstream_name }};
  295. {{ end }}
  296. {{ if (exists (printf "/etc/nginx/htpasswd/%s" $host)) }}
  297. auth_basic "Restricted {{ $host }}";
  298. auth_basic_user_file {{ (printf "/etc/nginx/htpasswd/%s" $host) }};
  299. {{ end }}
  300. {{ if (exists (printf "/etc/nginx/vhost.d/%s_location" $host)) }}
  301. include {{ printf "/etc/nginx/vhost.d/%s_location" $host}};
  302. {{ else if (exists "/etc/nginx/vhost.d/default_location") }}
  303. include /etc/nginx/vhost.d/default_location;
  304. {{ end }}
  305. }
  306. }
  307. {{ if (and (not $is_https) (exists "/etc/nginx/certs/default.crt") (exists "/etc/nginx/certs/default.key")) }}
  308. server {
  309. server_name {{ $host }};
  310. listen 443 ssl http2 {{ $default_server }};
  311. {{ if $enable_ipv6 }}
  312. listen [::]:443 ssl http2 {{ $default_server }};
  313. {{ end }}
  314. access_log /var/log/nginx/access.log vhost;
  315. return 500;
  316. ssl_certificate /etc/nginx/certs/default.crt;
  317. ssl_certificate_key /etc/nginx/certs/default.key;
  318. }
  319. {{ end }}
  320. {{ end }}
  321. {{ end }}