
우분투 18.04에서 Apache 2.4.29를 실행 중이고 000-default.conf에 다음 설정이 있습니다.
<VirtualHost *:80>
ServerName example.com
Redirect permanent / https://example.com/
</VirtualHost>
<VirtualHost *:443>
ServerName example.com
DocumentRoot /var/www/html
LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error_ssl.log
CustomLog ${APACHE_LOG_DIR}/access_ssl.log combined
SSLEngine on
SSLProxyEngine On
SSLCertificateKeyFile /pathtokey/privkey.pem
SSLCertificateChainFile /pathtokey/chain.pem
SSLCertificateFile /pathtokey/fullchain.pem
ProxyRequests Off
ProxyPreserveHost On
ProxyPass / https://localhost:8443/
ProxyPassReverse / https://localhost:8443/
#ErrorLog ${APACHE_LOG_DIR}/error.log
#CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Apache는 SSL을 사용하여 Tomcat 서버에 대한 프록시로 작동합니다. https와 함께 URL을 사용하면 apache가 잘 작동하지만 http를 사용하려고 하면 https로 리디렉션되지 않습니다. 확인해 보니 Apache가 포트 80의 연결을 수신하지 않거나 처리하지 않는 것 같습니다(텔넷으로도 확인했습니다).
SSL 설정을 제거하고 하나의 가상 호스트를 포트 80에 유지하면 SSL 없이도 작업할 수 있으며 포트 80에서는 제대로 작동하지만 SSL을 활성화하면 https로만 서버를 사용할 수 있습니다.
http를 사용하고 https로 리디렉션되는 방법이 있습니까?
답변1
문제를 발견했습니다. IPTABLES에 포트 80에서 8080으로 트래픽을 보내는 라우팅이 있었습니다.