我有一个带有多个网站的 RHEL 服务器。对于这个特定站点,有三个不同的域/子域可以访问它。两项工作,一项抛出错误。这是我的conf文件:
<VirtualHost *:80>
DocumentRoot /var/www/html/yln/web
ServerName portal.yln.info
ServerAlias www.yln.info
ServerAlias yln.info
Redirect "/" "https://portal.yln.info/"
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/html/yln>
Options +FollowSymLinks +ExecCGI
RewriteEngine On
AllowOverride All
Require all granted
</Directory>
ScriptAlias /cgi-bin/ /var/www/cgi-bin/
<Directory "/var/www/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Require all granted
</Directory>
ErrorLog /var/log/httpd/yln_error_log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/httpd/yln_access_log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
<VirtualHost *:443>
DocumentRoot /var/www/html/yln/web
ServerName portal.yln.info
ServerAlias www.yln.info
ServerAlias yln.info
SSLEngine on
SSLCertificateFile /etc/pki/tls/certs/1d40117d24e9b169.crt
SSLCertificateKeyFile /etc/pki/tls/private/yln.key
SSLCertificateChainFile /etc/pki/tls/certs/gd_bundle-g2-g1.crt
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/html/yln>
Options +FollowSymLinks +ExecCGI
RewriteEngine On
AllowOverride All
Require all granted
</Directory>
ScriptAlias /cgi-bin/ /var/www/cgi-bin/
<Directory "/var/www/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Require all granted
</Directory>
ErrorLog /var/log/httpd/yln_error_log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/httpd/yln_access_log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
portal.yln.info
、www.yln.info
和 可以http://yln.info
工作,但https://yln.info
(注意“s”)返回 403 Forbidden 错误。
日志中是这样的:
[Fri Oct 21 06:48:05.284438 2022] [autoindex:error] [pid 16786:tid 140094660904704] [client 63.226.23.69:26860] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.html,index.php) found, and server-generated directory index forbidden by Options directive
为什么 Apache 尝试从我未设置为文档根目录的目录提供索引文件?为什么它只是这样做https://yln.info
?
更新:在我展示的conf文件中,它捕获portal.yln.info和portal.yln.info并将它们发送到正确的位置(相同的域,SSL上下文)。正如我所说,浏览器返回 403 Forbidden 错误,我列出了日志显示的内容。除了 yln.info 之外,http 和 https 的所有变体都可以使用。
SSL 证书是 *.yln.info 的通配符。我还应该注意到,该服务器上的旧站点使用 yln.info 就很好。 (当我安装新的conf文件时,我将该conf文件重命名为旧的。)