안녕하세요,
현재 자체 호스팅 중인 Discourse 인스턴스에 내부 스캐너의 요구 사항에 따라 STS 헤더에 "IncludeSubDomains"를 추가해야 합니다.
이전에는 빌드 후 커스텀 명령에서 sed 명령을 사용하여 app.yml에 /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
이전에는 이 방식이 작동했습니다. 그러나 지금은 작동하지 않습니다. 새로운 outlet 파일을 생성하면 다음을 사용하여 이를 추가할 수 있다는 내용을 읽었습니다:
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;
하지만 이렇게 하면 STS 헤더가 두 개 존재하게 됩니다(하나는 SSL 템플릿에서, 다른 하나는 제 새 템플릿에서). STS 헤더가 두 개가 되지 않도록 하는 더 나은 방법이 있을까요? nginx는 마지막에 추가된 헤더를 존중하고, 단순히 max-age=31536000; 만 포함하는 SSL 템플릿 헤더를 무시할 것이라고 생각했는데, 이것이 결함(defect)인 것일까요? 조언해 주시면 감사하겠습니다.