一台 Apache2 服务器上的两个 SSL 域;一个服务正确,另一个服务于 'Index of /' 页面
Two SSL domains on one Apache2 server; one is served correctly, the other serves the 'Index of /' page
我在 Ubuntu 上的 Apache2 服务器 运行 上有两个受 SSL 保护的域。 site2.com
提供正确,但 site1.me
提供 Index of /
页面,其中 /
显然是两个站点的父目录。在 Index of /
页面中,我看到了两个站点的目录(site1-me
和 site2-com
),单击它们可以按预期提供页面,但在 URL site1.me/site1-me
或 site1.me/site2-com
.
我的配置文件的相关部分(或者,至少,我认为是相关的)在下面,删除了域名(左 TLD):
# Host multiple domains
NameVirtualHost *:80
<VirtualHost *:80>
ServerName site1.me
DocumentRoot "/var/www/html/site1-me"
ServerAlias *.site1.me
ServerAdmin admin@site1.me
RewriteEngine on
RewriteCond %{SERVER_NAME} =site1.me
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
ErrorLog /var/log/apache2/site1-me/site1-me-error.log
CustomLog /var/log/apache2/site1-me/site1-me-access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerName site2.com
DocumentRoot "/var/www/html/site2-com"
ServerAlias *.site2.com
ServerAdmin admin@site1.me
RewriteEngine on
RewriteCond %{SERVER_NAME} =site2.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
ErrorLog /var/log/apache2/site2-com/site2-com-error.log
CustomLog /var/log/apache2/site2-com/site2-com-access.log combined
</VirtualHost>
Rewrite*
行由 certbot
自动添加。
到目前为止我尝试过的:
- 正在为两个站点重新颁发 SSL 证书
- 正在重启服务器
- 正在检查两个站点目录的 owner/permissions。它们是相同的。
- 颠倒
<VirtualHost>
个区域的顺序
- 删除
Rewrite*
行
配置文件已在 /etc/apache2/apache2.conf
中正确配置,但是我在 /etc/apache2/sites-available/000-default-le-ssl.conf
中将 DocumentRoot
指定为 /var/www/html
。将适当的行更改为 DocumentRoot /var/www/html/site1-me
解决了这个问题。 site2
在 sites-available
目录中找不到。
这里要吸取的更重要的教训是我的配置文件目前一团糟,并且可能只能使用大量的错误处理。
我在 Ubuntu 上的 Apache2 服务器 运行 上有两个受 SSL 保护的域。 site2.com
提供正确,但 site1.me
提供 Index of /
页面,其中 /
显然是两个站点的父目录。在 Index of /
页面中,我看到了两个站点的目录(site1-me
和 site2-com
),单击它们可以按预期提供页面,但在 URL site1.me/site1-me
或 site1.me/site2-com
.
我的配置文件的相关部分(或者,至少,我认为是相关的)在下面,删除了域名(左 TLD):
# Host multiple domains
NameVirtualHost *:80
<VirtualHost *:80>
ServerName site1.me
DocumentRoot "/var/www/html/site1-me"
ServerAlias *.site1.me
ServerAdmin admin@site1.me
RewriteEngine on
RewriteCond %{SERVER_NAME} =site1.me
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
ErrorLog /var/log/apache2/site1-me/site1-me-error.log
CustomLog /var/log/apache2/site1-me/site1-me-access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerName site2.com
DocumentRoot "/var/www/html/site2-com"
ServerAlias *.site2.com
ServerAdmin admin@site1.me
RewriteEngine on
RewriteCond %{SERVER_NAME} =site2.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
ErrorLog /var/log/apache2/site2-com/site2-com-error.log
CustomLog /var/log/apache2/site2-com/site2-com-access.log combined
</VirtualHost>
Rewrite*
行由 certbot
自动添加。
到目前为止我尝试过的:
- 正在为两个站点重新颁发 SSL 证书
- 正在重启服务器
- 正在检查两个站点目录的 owner/permissions。它们是相同的。
- 颠倒
<VirtualHost>
个区域的顺序 - 删除
Rewrite*
行
配置文件已在 /etc/apache2/apache2.conf
中正确配置,但是我在 /etc/apache2/sites-available/000-default-le-ssl.conf
中将 DocumentRoot
指定为 /var/www/html
。将适当的行更改为 DocumentRoot /var/www/html/site1-me
解决了这个问题。 site2
在 sites-available
目录中找不到。
这里要吸取的更重要的教训是我的配置文件目前一团糟,并且可能只能使用大量的错误处理。