드디어 시간을 내어 "여러 도메인으로 Let’s Encrypt 설정하기"와 “단일/여러 도메인을 Discourse 인스턴스로 리디렉션하기” 가이드를 모두 읽어 보았습니다.
컨테이너의 app.yml 파일에 여러분이 하신 것보다 훨씬 더 많은 내용을 추가했는데, 거의 모든 것이 정상적으로 작동합니다.
제 Discourse는 www. 서브도메인에 호스팅되어 있으며, 제 목표는 apex 도메인에서의 http 및 https 요청을 www 서브도메인으로 리디렉션하는 것이었습니다. 지금은 이것이 작동하지만, https://mydomain.com으로 이동하면 리디렉션은 수행되지만 Chrome 콘솔에 다음과 같은 경고가 표시됩니다:
Redirecting navigation example.com -> www.example.com because the server presented a certificate valid for www.example.com but not for example.com. To disable such redirects launch Chrome with the following flag: --disable-features=SSLCommonNameMismatchHandling
제 app.yml 추가 내용은 다음과 같습니다:
after_ssl:
- replace:
filename: "/etc/runit/1.d/letsencrypt"
from: /--keylength/
to: "-d example.com -d www.example.com --keylength"
- replace:
filename: "/etc/nginx/conf.d/discourse.conf"
from: /return 301 https.+/
to: |
return 301 https://$host$request_uri;
- replace:
filename: "/etc/nginx/conf.d/discourse.conf"
from: /gzip on;[^\}]+\}/m
to: |
gzip on;
add_header Strict-Transport-Security 'max-age=31536000'; # remember the certificate for a year and automatically connect to HTTPS for this domain
after_web_config:
- replace:
filename: /etc/nginx/nginx.conf
from: /sendfile.+on;/
to: |
server_names_hash_bucket_size 64;
sendfile on;
- file:
path: /etc/nginx/conf.d/discourse_redirect_1.conf
contents: |
server {
listen 80;
listen 443 ssl;
server_name example.com;
return 301 https://www.example.com$request_uri;
}
이것이 올바르게 보입니까? 그렇다면 인증서 이름 불일치 문제에 대한 해결책이 있을까요?
수정: www 서브도메인을 위한 A 레코드와 apex 도메인으로의 모든 요청을 잡아내는 @를 사용하는 A 레코드 두 개를 가지고 있습니다. 둘 다 제 Digital Ocean 드롭렛 IP를 가리킵니다. 이것도 올바른 설정이라고 가정해도 될까요?
감사합니다.