요약
이 커밋 시점부터 Discourse의 기본 nginx 구성에는 'outlet(아웃렛)'이라 불리는 기능이 포함되어 있습니다. 이는 nginx 구성의 적절한 위치에 추가 지문을 주입하기 위한 지원되는 방식입니다.
이 변경 사항은 이전에 상대적으로 취약한 검색/교체 명령에 의존하던 웹 서버의 구성 및 동작을 관리하는 보다 견고한 접근 방식을 가능하게 합니다.
시간이 지남에 따라 우리는 자체 구성 템플릿을 아웃렛을 사용하도록 적응시켜 나갈 것입니다.
사용법
지원되는 아웃렛 섹션은 세 가지입니다:
before-server:http컨텍스트 구성 지문server:server컨텍스트 구성 지문discourse:location컨텍스트 구성 지문 - 이 지문들은 Discourse로 전달되는 요청에 적용됩니다
예시
app.yml 구성 파일에서 이러한 아웃렛을 사용하여 목표를 달성하는 몇 가지 예시를 보여줍니다.
run 또는 file 명령을 사용할 수 있는 어디에나 추가할 수 있지만, 문법 오류가 있는 경우 재빌드(rebuild)가 빠르게 실패하도록 after_code 훅에서 수행하는 것을 권장합니다.
응답 헤더 추가
이 예시는 Discourse로 전달되는 각 응답에 헤더를 추가합니다:
hooks:
after_code:
- file:
path: /etc/nginx/conf.d/outlets/discourse/clacks-overhead.conf
chmod: 444
contents: |
add_header x-clacks-overhead "GNU Terry Pratchett";
결과:
○ → curl -I https://example.contoso.com/
HTTP/2 200
…
x-clacks-overhead: GNU Terry Pratchett
단일 경로에 정적 파일 추가
이 예시는 일반적인 Discourse 트리 외부에서 nginx가 제공하는 단일 경로에 정적 파일을 추가합니다.
hooks:
after_code:
- file:
path: /etc/nginx/conf.d/outlets/server/well-known-important-file.conf
chmod: 444
contents: |
location = /.well-known/important-file {
default_type application/json;
root /var/www/static/;
}
- file:
path: /var/www/static/.well-known/important-file
chmod: 444
contents: |
{"content-free":true}
결과:
○ → curl -i https://example.contoso.com/.well-known/important-file
HTTP/2 200
server: nginx
date: Fri, 07 Mar 2025 23:22:38 GMT
content-type: application/json
content-length: 22
last-modified: Fri, 07 Mar 2025 23:12:08 GMT
strict-transport-security: max-age=63072000
accept-ranges: bytes
{"content-free":true}