20610: Tweaks controller's nginx pillar to support "balanced mode".
[arvados.git] / tools / salt-install / config_examples / multi_host / aws / pillars / nginx_balancer_configuration.sls
1 ---
2 # Copyright (C) The Arvados Authors. All rights reserved.
3 #
4 # SPDX-License-Identifier: AGPL-3.0
5
6 {%- import_yaml "ssl_key_encrypted.sls" as ssl_key_encrypted_pillar %}
7 {%- set domain = "__DOMAIN__" %}
8 {%- set enable_balancer = ("__ENABLE_BALANCER__"|to_bool) %}
9 {%- set balancer_backends = "__BALANCER_BACKENDS__".split(",") if enable_balancer else [] %}
10
11 ### NGINX
12 nginx:
13   ### SERVER
14   server:
15     config:
16       ### STREAMS
17       http:
18         'geo $external_client':
19           default: 1
20           '127.0.0.0/8': 0
21           '__CLUSTER_INT_CIDR__': 0
22         upstream controller_upstream:
23         {%- for backend in balancer_backends %}
24           'server {{ backend }}.{{ domain }}:80': ''
25         {%- endfor %}
26
27   ### SNIPPETS
28   snippets:
29     # Based on https://ssl-config.mozilla.org/#server=nginx&version=1.14.2&config=intermediate&openssl=1.1.1d&guideline=5.4
30     ssl_hardening_default.conf:
31       - ssl_session_timeout: 1d
32       - ssl_session_cache: 'shared:arvadosSSL:10m'
33       - ssl_session_tickets: 'off'
34
35       # intermediate configuration
36       - ssl_protocols: TLSv1.2 TLSv1.3
37       - 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
38       - ssl_prefer_server_ciphers: 'off'
39
40       # HSTS (ngx_http_headers_module is required) (63072000 seconds)
41       - add_header: 'Strict-Transport-Security "max-age=63072000" always'
42
43       # OCSP stapling
44       - ssl_stapling: 'on'
45       - ssl_stapling_verify: 'on'
46
47       # verify chain of trust of OCSP response using Root CA and Intermediate certs
48       # - ssl_trusted_certificate /path/to/root_CA_cert_plus_intermediates
49
50       # curl https://ssl-config.mozilla.org/ffdhe2048.txt > /path/to/dhparam
51       # - ssl_dhparam: /path/to/dhparam
52
53       # replace with the IP address of your resolver
54       # - resolver: 127.0.0.1
55
56   ### SITES
57   servers:
58     managed:
59       # Remove default webserver
60       default:
61         enabled: false
62       ### DEFAULT
63       arvados_balancer_default.conf:
64         enabled: true
65         overwrite: true
66         config:
67           - server:
68             - server_name: {{ domain }}
69             - listen:
70               - 80 default
71             - location /.well-known:
72               - root: /var/www
73             - location /:
74               - return: '301 https://$host$request_uri'
75
76       arvados_balancer_ssl.conf:
77         enabled: true
78         overwrite: true
79         requires:
80           __CERT_REQUIRES__
81         config:
82           - server:
83             - server_name: {{ domain }}
84             - listen:
85               - __CONTROLLER_EXT_SSL_PORT__ http2 ssl
86             - index: index.html index.htm
87             - location /:
88               - proxy_pass: 'http://controller_upstream'
89               - proxy_read_timeout: 300
90               - proxy_connect_timeout: 90
91               - proxy_redirect: 'off'
92               - proxy_set_header: X-Forwarded-Proto https
93               - proxy_set_header: 'Host $http_host'
94               - proxy_set_header: 'X-Real-IP $remote_addr'
95               - proxy_set_header: 'X-Forwarded-For $proxy_add_x_forwarded_for'
96               - proxy_set_header: 'X-External-Client $external_client'
97               - proxy_set_header: 'Upgrade $http_upgrade'
98               - proxy_set_header: 'Connection "upgrade"'
99               - proxy_max_temp_file_size: 0
100               - proxy_request_buffering: 'off'
101               - proxy_buffering: 'off'
102               - proxy_http_version: '1.1'
103             - include: snippets/ssl_hardening_default.conf
104             - ssl_certificate: __CERT_PEM__
105             - ssl_certificate_key: __CERT_KEY__
106             {%- if ssl_key_encrypted_pillar.ssl_key_encrypted.enabled %}
107             - ssl_password_file: {{ '/run/arvados/' | path_join(ssl_key_encrypted_pillar.ssl_key_encrypted.privkey_password_filename) }}
108             {%- endif %}
109             - access_log: /var/log/nginx/{{ domain }}.access.log combined
110             - error_log: /var/log/nginx/{{ domain }}.error.log
111             - client_max_body_size: 128m