【发布时间】:2020-04-16 08:32:39
【问题描述】:
为了保护我的网站,我在 Ubuntu 上使用 apache2 和 acme 与letsencrypt。 我也想从 http://mywebsite.com 重定向到 https://mywebsite.com 但这不适用于以下配置:
文件名-xy.conf 如下:
<VirtualHost *:80>
ServerName mywebsite.com
ProxyRequests off
ProxyPreserveHost On
<Location / >
ProxyPass "ajp://localhost:9090/"
ProxyPassReverse "ajp://localhost:9090/"
</Location>
</VirtualHost>
文件名-xy-ssl.conf 如下所示:
<VirtualHost *:80>
ServerName mywebsite.com
RewriteEngine on
#RewriteCond %{SERVER_NAME} =www.mywebsite.com [OR]
RewriteCond %{HTTPS} =mywebsite.com
RewriteRule (.*) https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
# forward ORDS requests to tomcat
<VirtualHost *:443>
ServerName mywebsite.com
# SSL certificates settings
#Include /etc/apache2/conf-enabled/options-ssl-apache.conf
SSLCertificateFile /etc/apache2/ssl/mywebsite.com/fullchain.cer
SSLCertificateKeyFile /etc/apache2/ssl/mywebsite.com/mywebsite.com.key
SSLCertificateChainFile /etc/apache2/ssl/mywebsite.com/ca.cer
ProxyRequests on
ProxyPreserveHost On
<Location / >
ProxyPass "ajp://localhost:9090/"
ProxyPassReverse "ajp://localhost:9090/"
</Location>
</VirtualHost>
有了这个配置,我将导航到默认的 apache2 主页,https://mywebpage.com 工作正常。 为了自动从http://mywebsite.com 重定向到https://mywebsite.com,这个配置有什么问题?
【问题讨论】:
标签: apache2 lets-encrypt acme