|  | 
| 1 | 1 | run: | 
| 2 | 2 |   - exec: | 
| 3 |  | -      cmd: | 
| 4 |  | -        - "mkdir -p /shared/ssl/" | 
| 5 |  | -  - file: | 
| 6 |  | -      path: "/etc/nginx/conf.d/outlets/before-server/10-redirect-http-to-https.conf" | 
| 7 |  | -      contents: | | 
| 8 |  | -        server { | 
| 9 |  | -          listen 80; | 
| 10 |  | -          return 301 https://$$ENV_DISCOURSE_HOSTNAME$request_uri; | 
| 11 |  | -        } | 
| 12 |  | -  - exec: rm /etc/nginx/conf.d/outlets/server/10-http.conf | 
| 13 |  | -  - file: | 
| 14 |  | -      hook: ssl | 
| 15 |  | -      path: "/etc/nginx/conf.d/outlets/server/20-https.conf" | 
| 16 |  | -      contents: | | 
| 17 |  | -        listen 443 ssl; | 
| 18 |  | -        http2 on; | 
|  | 3 | +     cmd: | 
|  | 4 | +       - "mkdir -p /shared/ssl/" | 
|  | 5 | +  - replace: | 
|  | 6 | +     filename: "/etc/nginx/conf.d/discourse.conf" | 
|  | 7 | +     from: /listen 80;\s+listen \[::\]:80;/m | 
|  | 8 | +     to: | | 
|  | 9 | +       listen 443 ssl; | 
|  | 10 | +       listen [::]:443 ssl; | 
|  | 11 | +       http2 on; | 
|  | 12 | +       SSL_TEMPLATE_SSL_BLOCK | 
|  | 13 | +  - replace: | 
|  | 14 | +     filename: "/etc/nginx/conf.d/discourse.conf" | 
|  | 15 | +     from: /listen 80;/ | 
|  | 16 | +     to: | | 
|  | 17 | +       listen 443 ssl; | 
|  | 18 | +       http2 on; | 
|  | 19 | +       SSL_TEMPLATE_SSL_BLOCK | 
|  | 20 | +  - replace: | 
|  | 21 | +     hook: ssl | 
|  | 22 | +     filename: "/etc/nginx/conf.d/discourse.conf" | 
|  | 23 | +     from: /SSL_TEMPLATE_SSL_BLOCK/ | 
|  | 24 | +     to: | | 
| 19 | 25 | 
 | 
| 20 |  | -        ssl_protocols TLSv1.2 TLSv1.3; | 
| 21 |  | -        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; | 
| 22 |  | -        ssl_prefer_server_ciphers off; | 
|  | 26 | +       ssl_protocols TLSv1.2 TLSv1.3; | 
|  | 27 | +       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; | 
|  | 28 | +       ssl_prefer_server_ciphers off; | 
| 23 | 29 | 
 | 
| 24 |  | -        ssl_certificate /shared/ssl/ssl.crt; | 
| 25 |  | -        ssl_certificate_key /shared/ssl/ssl.key; | 
|  | 30 | +       ssl_certificate /shared/ssl/ssl.crt; | 
|  | 31 | +       ssl_certificate_key /shared/ssl/ssl.key; | 
| 26 | 32 | 
 | 
| 27 |  | -        ssl_session_tickets off; | 
| 28 |  | -        ssl_session_timeout 1d; | 
| 29 |  | -        ssl_session_cache shared:SSL:1m; | 
|  | 33 | +       ssl_session_tickets off; | 
|  | 34 | +       ssl_session_timeout 1d; | 
|  | 35 | +       ssl_session_cache shared:SSL:1m; | 
| 30 | 36 | 
 | 
| 31 |  | -        add_header Strict-Transport-Security 'max-age=31536000'; | 
|  | 37 | +       add_header Strict-Transport-Security 'max-age=31536000'; # remember the certificate for a year and automatically connect to HTTPS for this domain | 
| 32 | 38 | 
 | 
| 33 |  | -        if ($http_host != $$ENV_DISCOURSE_HOSTNAME) { | 
|  | 39 | +       if ($http_host != $$ENV_DISCOURSE_HOSTNAME) { | 
| 34 | 40 |           rewrite (.*) https://$$ENV_DISCOURSE_HOSTNAME$1 permanent; | 
| 35 |  | -        } | 
| 36 |  | -  - file: | 
| 37 |  | -      path: "/etc/nginx/conf.d/outlets/discourse/20-https.conf" | 
| 38 |  | -      contents: | | 
| 39 |  | -        add_header Strict-Transport-Security 'max-age=31536000'; | 
| 40 |  | -  - exec: | 
| 41 |  | -      cmd: | 
| 42 |  | -        - |- | 
| 43 |  | -          if [ -f "/proc/net/if_inet6" ] ; then | 
| 44 |  | -            sed -i 's/listen 80;/listen 80;\nlisten [::]:80;/g' /etc/nginx/conf.d/outlets/before-server/10-redirect-http-to-https.conf | 
| 45 |  | -            sed -i 's/listen 443 ssl;/listen 443 ssl;\nlisten [::]:443 ssl;/g' /etc/nginx/conf.d/outlets/server/20-https.conf | 
| 46 |  | -          fi | 
|  | 41 | +       } | 
|  | 42 | +  - replace: | 
|  | 43 | +     filename: "/etc/nginx/conf.d/discourse.conf" | 
|  | 44 | +     from: "location @discourse {" | 
|  | 45 | +     to: | | 
|  | 46 | +       location @discourse { | 
|  | 47 | +       add_header Strict-Transport-Security 'max-age=31536000'; # remember the certificate for a year and automatically connect to HTTPS for this domain | 
|  | 48 | +  - replace: | 
|  | 49 | +     filename: "/etc/nginx/conf.d/discourse.conf" | 
|  | 50 | +     from: /server.+{/ | 
|  | 51 | +     to: | | 
|  | 52 | +       server { | 
|  | 53 | +         listen 80; | 
|  | 54 | +         return 301 https://$$ENV_DISCOURSE_HOSTNAME$request_uri; | 
|  | 55 | +       } | 
|  | 56 | +       server { | 
0 commit comments