皆さん、こんにちは。
現在セルフホストしているDiscourseインスタンスについて、社内スキャナーの要件により、STSヘッダーに「IncludeSubDomains」を追加する必要があります。
以前は、ビルド後のカスタムコマンドでapp.yml内のsedコマンドを使用して、/etc/nginx/conf.d/discourse.confを更新し、'add_header Strict-Transport-Security “max-age=31536000; includeSubDomains” always;を含めることでこれを実現していました。
また、以下も使用していました。
- replace:
filename: "/etc/nginx/conf.d/outlets/discourse/20-https.conf"
from: /add_header Strict-Transport-Security.+/
to: add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
global: true
- replace:
filename: "/etc/nginx/conf.d/outlets/server/20-https.conf"
from: /add_header Strict-Transport-Security.+/
to: add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
global: true
これは以前は機能していましたが、機能しなくなりました。新しいアウトレットファイルを作成することで、以下を使用して追加できると読みました。
hooks:
after_code:
- file:
path: /etc/nginx/conf.d/outlets/server/90-hsts.conf
chmod: 444
contents: |
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
しかし、これによりSSLテンプレートからのものと新しいテンプレートからのものの2つのSTSヘッダーが存在することになります。2つのSTSヘッダーが発生しないようにするためのより良い方法はありますか?Nginxは最後に追加されたヘッダーを尊重し、max-age=31536000; のみを含むSSLテンプレートのヘッダーは無視するはずなので、これは欠陥でしょうか?ご指導いただければ幸いです。