Skip to content

Commit

Permalink
FIX: web.ssl.template compat with latest core (#938)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
davidtaylorhq authored Feb 4, 2025
1 parent e570a8c commit efd6bc8
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions templates/web.ssl.template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,17 @@ run:
- "mkdir -p /shared/ssl/"
- replace:
filename: "/etc/nginx/conf.d/discourse.conf"
from: /server.+{/
to: |
server {
listen 80;
return 301 https://$$ENV_DISCOURSE_HOSTNAME$request_uri;
}
server {
- replace:
filename: "/etc/nginx/conf.d/discourse.conf"
from: /listen 80;\s+gzip on;/m
from: /listen 80;\s+listen \[::\]:80;/m
to: |
listen 443 ssl;
listen [::]:443 ssl;
http2 on;
SSL_TEMPLATE_SSL_BLOCK
- replace:
filename: "/etc/nginx/conf.d/discourse.conf"
from: /listen 80;\s+listen \[::\]:80;\s+gzip on;/m
from: /listen 80;/
to: |
listen 443 ssl;
listen [::]:443 ssl;
http2 on;
SSL_TEMPLATE_SSL_BLOCK
- replace:
Expand All @@ -43,8 +34,6 @@ run:
ssl_session_timeout 1d;
ssl_session_cache shared:SSL:1m;
gzip on;
add_header Strict-Transport-Security 'max-age=31536000'; # remember the certificate for a year and automatically connect to HTTPS for this domain
if ($http_host != $$ENV_DISCOURSE_HOSTNAME) {
Expand All @@ -56,3 +45,12 @@ run:
to: |
location @discourse {
add_header Strict-Transport-Security 'max-age=31536000'; # remember the certificate for a year and automatically connect to HTTPS for this domain
- replace:
filename: "/etc/nginx/conf.d/discourse.conf"
from: /server.+{/
to: |
server {
listen 80;
return 301 https://$$ENV_DISCOURSE_HOSTNAME$request_uri;
}
server {

1 comment on commit efd6bc8

@discoursebot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit has been mentioned on Discourse Meta. There might be relevant details there:

https://meta.discourse.org/t/site-offline-after-rebuild-4th-feb-2025/350495/7

Please sign in to comment.