您可能会发现,在此前的建议中用于编辑配置的类似技术对您来说是有效的:
(摘自此维基帖子的先前版本:Set up Let’s Encrypt with multiple domains / redirects
“这真的很简单,在您的 app.yml 钩子部分添加类似以下内容:
步骤 2 - discourse.conf
除了步骤 1,还需要更改 nginx 以正确地将除 DISCOURSE_HOSTNAME 之外的所有 http 重定向到 https
- replace:
filename: "/etc/nginx/conf.d/discourse.conf"
from: /return 301 https.+/
to: |
return 301 https://$host$request_uri;
我们还需要删除 web.ssl.template.yml 添加的额外重写,因为它只强制使用 DISCOURSE_HOSTNAME,而现在我们有其他主机了!
- replace:
filename: "/etc/nginx/conf.d/discourse.conf"
from: /gzip on;[^\\}]+\\}/m
to: |
gzip on;
add_header Strict-Transport-Security 'max-age=31536000'; # 记住此域的证书一年,并自动连接到 HTTPS