【发布时间】:2019-10-08 17:24:58
【问题描述】:
我已经使用 certbot 成功安装了 SSL 证书,并且可以在我的 google cloud 上的 debian 和 apache linux 虚拟机上进行加密。
该域已通过 HTTPS 成功保护。
虽然在直接访问外部 IP 地址时,我仍然会得到一个不安全的网站版本。 如何将 ip 直接重定向到使用 APACHE 设置的 HTTPS 版本,并将“domain.com”重定向到 -->> HTTPs:www.domain.com 。
我尝试像在 PHP 中一样将端口 80 和 443 重新路由到 HTTPS 版本,但没有任何运气,如下所示: How to redirect from www to https www with htacces?
在我的 000-default.conf 中:
<VirtualHost *:80>
ServerName localhost
ServerAdmin webmaster@localhost
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.bracketline.com [OR]
RewriteCond %{SERVER_NAME} =localhost
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI}
[END,NE,R=permanent]
</VirtualHost>
在我的 000-default-le-ssl.conf 我有:
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName localhost
ServerAdmin webmaster@localhost
Alias /static /var/www/static-root
<Directory /var/www/static-root>
Require all granted
</Directory>
Alias /media /var/www/media-root
<Directory /var/www/media-root>
Require all granted
</Directory>
<Directory /var/www/venv/src/cfehome>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIDaemonProcess cfehome python-
path=/var/www/venv/src/:/var/www/venv/lib/python3.5/site-packages
WSGIProcessGroup cfehome
WSGIScriptAlias / /var/www/venv/src/cfehome/wsgi.py
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
ServerAlias www.bracketline.com
SSLCertificateFile
/etc/letsencrypt/live/www.bracketline.com/fullchain.pem
SSLCertificateKeyFile
/etc/letsencrypt/live/www.bracketline.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>
我不确定这东西是如何工作的,如果可以提供详细的博客或教程,那将有很大的帮助。提前谢谢!
【问题讨论】:
标签: django apache google-cloud-platform debian virtual-machine