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