Skip to content

Commit efd6bc8

Browse files
FIX: web.ssl.template compat with latest core (#938)
discourse/discourse@649505d added some new content between `listen 80;` and `gzip on;`, which broke these replacements. This commit reorders & updates the replacements so that they should work reliably with versions of core before and after that change.
1 parent e570a8c commit efd6bc8

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

templates/web.ssl.template.yml

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,17 @@ run:
44
- "mkdir -p /shared/ssl/"
55
- replace:
66
filename: "/etc/nginx/conf.d/discourse.conf"
7-
from: /server.+{/
8-
to: |
9-
server {
10-
listen 80;
11-
return 301 https://$$ENV_DISCOURSE_HOSTNAME$request_uri;
12-
}
13-
server {
14-
- replace:
15-
filename: "/etc/nginx/conf.d/discourse.conf"
16-
from: /listen 80;\s+gzip on;/m
7+
from: /listen 80;\s+listen \[::\]:80;/m
178
to: |
189
listen 443 ssl;
10+
listen [::]:443 ssl;
1911
http2 on;
2012
SSL_TEMPLATE_SSL_BLOCK
2113
- replace:
2214
filename: "/etc/nginx/conf.d/discourse.conf"
23-
from: /listen 80;\s+listen \[::\]:80;\s+gzip on;/m
15+
from: /listen 80;/
2416
to: |
2517
listen 443 ssl;
26-
listen [::]:443 ssl;
2718
http2 on;
2819
SSL_TEMPLATE_SSL_BLOCK
2920
- replace:
@@ -43,8 +34,6 @@ run:
4334
ssl_session_timeout 1d;
4435
ssl_session_cache shared:SSL:1m;
4536
46-
gzip on;
47-
4837
add_header Strict-Transport-Security 'max-age=31536000'; # remember the certificate for a year and automatically connect to HTTPS for this domain
4938
5039
if ($http_host != $$ENV_DISCOURSE_HOSTNAME) {
@@ -56,3 +45,12 @@ run:
5645
to: |
5746
location @discourse {
5847
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

Comments
 (0)