在我的 Apache 2.4 服务器配置虚拟主机文件的第二次调用中,我有:
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName 51.89.98.21
RewriteEngine On
RewriteCond %{HTTP_HOST} ^http://51.89.98.21$1 [NC]
RewriteRule ^(.*)$ http://51.89.98.21/ [R=permanent,END,QSA]
</VirtualHost>
第三个配置虚拟主机是这个(部分):
<VirtualHost *:443>
ServerAdmin [email protected]
ServerName www.developmentscout.com
ServerAlias developmentscout.com
UseCanonicalName Off
DocumentRoot "/var/www/vhosts/developmentscout.com/htdocs"
RewriteEngine On
RewriteCond %{REQUEST_URI} ^\.well\-known [NC,OR]
RewriteCond %{HTTP_HOST} ^developmentscout.com$ [NC]
RewriteRule ^ https://www.developmentscout.com%{REQUEST_URI} [END,QSA,R=permanent]
SSLEngine on
SSLCertificateKeyFile /etc/letsencrypt/live/developmentscout.com-0002/privkey.pem
SSLCertificateFile /etc/letsencrypt/live/developmentscout.com-0002/cert.pem
SSLCertificateChainFile /etc/letsencrypt/live/developmentscout.com-0002/chain.pem
...
https://51.89.98.21/industrie/automatisierung/ipc/11315-edge-computing的链接 应重定向到http://51.89.98.21但我重定向到:http://51.89.98.21/industrie/ automatisierung/ipc/11315-edge-computing,它向我显示“真实”页面的内容。
第二个虚拟主机永远无法到达,因为在日志中我有以下内容:
[Tue Oct 24 18:44:23.156932 2023] [ssl:debug] [pid 8958:tid 140379014039296] ssl_engine_kernel.c(383): [client 98.58.102.21:64004] AH02034: 后续 (No.3) HTTPS收到的请求子22272(服务器www.developmentscout.com:443),参考: https: //51.89.98.21/industrie/automatisierung/ipc/11315-edge-computing
显然,https 请求转到了错误的 URL,该 URL 调用了错误的 SSL 证书,然后使用了 http 连接并显示了内容。
我尝试使用 Letsencrypt 创建 SSL 证书,但这对于 IP 来说是不可能的。因此,任何如何解决这个问题的建议都会很棒。
更新:与此同时,我已经为 51.89.98.21 创建了一个自签名证书。(默认之后的第二个)虚拟主机是:
<VirtualHost *:443>
ServerAdmin [email protected]
ServerName 51.89.98.21
SSLEngine on
SSLCertificateKeyFile /etc/ca-certificates/key.pem
SSLCertificateFile /etc/ca-certificates/cert.pem
RewriteEngine On
RewriteCond %{HTTP_HOST} ^51.89.98.21/$ [NC]
RewriteRule ^ https://51.89.98.21/ [END,QSA,R=permanent]
DocumentRoot /var/www/server3
</VirtualHost>
当我调用此 URL:https://51.89.98.21/branche/automobil/11819-e-auto-laden-ladestecker-ladekabel时 ,我得到了 Not Found 404。