我已经在 HTTP 上设置了这个虚拟主机,不同的域将提供来自不同位置的文件。这是我的000-default.conf
文件:
<VirtualHost *:80>
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/root
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:80>
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ServerName nature.sentenceman.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/nature
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:80>
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ServerName games.sentenceman.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/games
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:80>
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ServerName katiebenson.co.uk
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/katie
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
这工作正常,你可以在这里看到:
然后我意识到,当通过 HTTPS 访问它们时,所有这些都只会提供根文件,这是因为我没有在我的000-default-le-ssl.conf
文件中复制这些虚拟主机。但是,我现在已经这样做了,但它似乎仍然不起作用,因为您可以看到您是否尝试通过 HTTPS 访问上述任何内容:
这是这个配置文件的样子:
<IfModule mod_ssl.c>
<VirtualHost *:443>
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/root
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
ServerName sentenceman.com
Include /etc/letsencrypt/options-ssl-apache.conf
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/sentenceman.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/sentenceman.com/privkey.pem
</VirtualHost>
<VirtualHost *:443>
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ServerName nature.sentenceman.com
Include /etc/letsencrypt/options-ssl-apache.conf
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/sentenceman.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/sentenceman.com/privkey.pem
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/nature
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:433>
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ServerName games.sentenceman.com
Include /etc/letsencrypt/options-ssl-apache.conf
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/sentenceman.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/sentenceman.com/privkey.pem
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/games
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:433>
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ServerName katiebenson.co.uk
Include /etc/letsencrypt/options-ssl-apache.conf
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/sentenceman.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/sentenceman.com/privkey.pem
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/katie
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
</IfModule>
我已经检查它是否已启用(我想否则我不应该得到任何东西HTTPS://
)。有人能看出这个设置有什么问题吗?
编辑:修复接受的答案https://katiebenson.com中提到的错误端口后,现在可以工作了!:D 其他两个没有,apache 错误日志告诉我原因:
[Sat Jul 25 17:54:11.755069 2020] [ssl:warn] [pid 27351] AH01909: games.sentenceman.com:443:0 server certificate does NOT include an ID which matches
the server name
[Sat Jul 25 17:54:11.755432 2020] [ssl:warn] [pid 27351] AH01909: nature.sentenceman.com:443:0 server certificate does NOT include an ID which matches
the server name
证书不是通配符证书(这是我的下一步要创建通配符证书)。
您的 HTTPS 虚拟主机
katiebenson.co.uk
和games.sentenceman.com
为端口 433 定义。实际的 HTTPS 端口是 443。