我已经在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
证书不是通配符证书(下一步是创建通配符证书)。
katiebenson.co.uk
并且games.sentenceman.com
为端口433定义了HTTPS虚拟主机。实际的HTTPS端口为443。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句