Ubuntu 18.04阿帕奇2Certbot
我正在尝试在这个网站上设置cerbot和非www到www的重定向,我正在从我的另一个网站复制conf文件,该文件运行良好,但由于某种原因,443被禁止在这个新网站上使用,非www.domain.url重定向到domain.url/www.domain.urlwww.domain.urlwww.domain.url等。
的main.conf
<VirtualHost *:80>
ServerName domain.url
Redirect permanent / https://www.domain.url/
</VirtualHost>
<VirtualHost *:80>
ServerName www.domain.url
ServerAdmin email@domain.url
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.domain.url
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
的main-le-sl.conf
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName www.domain.url
ServerAdmin email@domain.url
ServerAlias domain.url
DocumentRoot /var/www/html
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www. [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /static /home/user/project/static
<Directory /home/user/project/static>
Require all granted
</Directory>
<Directory /home/user/project/media>
Require all granted
</Directory>
<Directory /home/user/project>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIScriptAlias / /home/user/project/project/wsgi.py
WSGIDaemonProcess theprocess python-path=/home/user/prject python-home=/home/user/project/wow
WSGIProcessGroup theprocess
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/www.domain.url/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/www.domain.url/privkey.pem
</VirtualHost>
</IfModule>
ssh、http、https都是通过ufw启用的。我可能有权限问题,用户可以查看我的网站,但在安装certbot之前,它一直运行良好。现在所有内容(除了导致重复域问题的非https非www(都重定向到https://www.domain.url我收到一条被禁止的信息。
当我安装certbot时,我错过了非www域。当我返回并续订以获得www和非www时,重定向设置失败,但它说我有证书。这是造成问题的原因吗?我想我可以在配置文件中自己构建重定向。。。
这篇文章最终得到了答案:https://serverfault.com/questions/957788/forbidden-after-enabling-ssl
我的WSGIScriptAlias文件路径中出现了一个大小写错误。