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