apache - Ubuntu上的Apache conf导致url重复而不是重定向
问题描述
Ubuntu 18.04 Apache2 Certbot
我正在尝试在此站点上设置 cerbot 和非 www 到 www 重定向,并且我正在从另一个运行良好的站点复制 conf 文件,但由于某种原因,443 禁止用户使用此新站点和非 www.domain.url 重定向到 domain.url/www.domain.urlwww.domain.urlwww.domain.url 等。
主配置文件
<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-ssl.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 文件路径中有一个大小写错误。
推荐阅读
- r - R提取不同空间多边形属性的栅格和直方图
- c# - 如何先显示文本,直到从数据库 sql 检索图像
- mongodb - 使用 mongoDB 中的聚合查询以获取特定的子文档?
- css - 如何将两个 flexbox 容器并排设置
- ibeacon - 使用 Android 信标库进行传输时,无法在 Google Beacon Tools 应用程序的未注册选项卡中看到 Eddystone UID
- rdf - RDF 可以对带有边缘属性的标记属性图进行建模吗?
- javascript - querySelectorAll 返回的节点问题
- javascript - ASP.NET onClientClick 返回 false 不起作用
- react-native - 将 base64 图像 uri 发送到 ImageManipulator
- nativescript - 如何在 Nativescript 中为 TabViewItem 赋予宽度?