이 설정은 로컬호스트에서 Docker 컨테이너로 트래픽을 전달합니다. 이 작업을 수행한 후에는 ./launcher rebuild app 명령을 사용하여 재빌드가 필요합니다.
Apache2 2.4.43 (Ubuntu)
서브도메인용 새로운 가상 호스트를 sites-available에 discourse.<myDomain>.com.conf 파일로 추가하여, 서브도메인의 트래픽을 Discourse Docker 인스턴스가 수신 중인 localhost 포트로 전달하도록 설정했습니다. 가상 호스트 정의는 다음과 같습니다:
<VirtualHost *:80>
ServerName discourse.<myDomain>.com
Redirect permanent / https://discourse.<myDomain>.com/
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</VirtualHost>
<VirtualHost *:443>
ServerName discourse.<myDomain>.com
SSLProtocol TLSv1 TLSv1.1 TLSv1.2
SSLEngine on
SSLProxyEngine on
SSLCertificateFile /etc/letsencrypt/live/<myDomain>.com/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/<myDomain>.com/privkey.pem
SSLCACertificateFile /etc/letsencrypt/live/<myDomain>.com/chain.pem
SSLCipherSuite "EECDH+ECDSA+AESGCM:EECDH+aRSA+AESGCM:EECDH+ECDSA+SHA256:EECDH+aRSA+SHA256:EECDH+ECDSA+SHA384:EECDH+ECDSA+SHA256:EECDH+aRSA+SHA384:EDH+aRSA+AESGCM:EDH+aRSA+SHA256:EDH+aRSA:EECDH:!aNULL:!eNULL:!MEDIUM:!LOW:!3DES:!MD5:!EXP:!PSK:!SRP:!DSS:!RC4:!SEED"
SSLHonorCipherOrder on
Header set Strict-Transport-Security "max-age=31536000"
<Location />
Order allow,deny
Allow from all
Require all granted
</Location>
ProxyPreserveHost on
ProxyRequests Off
RequestHeader set X-Forwarded-Proto expr=%{REQUEST_SCHEME}
RequestHeader set X-Real-IP expr=%{REMOTE_ADDR}
ProxyPass / https://127.0.0.1:8443/
ProxyPassReverse / https://127.0.0.1:8443/
</VirtualHost>
Apache 설정에 많은 시간을 들이지 않기 때문에, 불필요한 줄이 있거나 추가하거나 개선할 수 있는 줄이 있을 수 있습니다. 피드백을 환영합니다.
직접 프록시 대신 유닉스 소켓을 사용하려면 app.yml에서 web.socketed.template.yml를 활성화한 후 다음과 같이 설정할 수 있습니다:
ProxyPreserveHost On
ProxyRequests Off
RequestHeader set X-Forwarded-Proto https
RequestHeader set X-Real-IP expr=%{REMOTE_ADDR}
<Location />
ProxyPass unix:/var/discourse/shared/standalone/nginx.http.sock|http://localhost/
ProxyPassReverse unix:/var/discourse/shared/standalone/nginx.http.sock|http://localhost/
</Location>
Apache가 /var/discourse에서 위와 같이 읽도록 하려면 SELinux 문제를 처리해야 할 가능성이 높다는 점에 유의하세요. semanage fcontext -a -t httpd_sys_rw_content_t /var/discourse/shared/standalone/nginx.http.sock 명령을 실행한 후 restorecon /var/discourse/shared/standalone/nginx.http.sock를 실행하면 해당 문제를 해결할 수 있습니다.
Apache에는 Let’s Encrypt 인증서를 자동으로 발급받아 주는 상당히 유용한 mod_md 모듈이 있습니다. 적극 권장합니다.