apache - 将 HTTP 重定向到 HTTPS 时,HTTPS 在外部客户端上中断

标签 apache ssl redirect https ssl-certificate

我在 Windows Server 2008 R2 上使用 Apache 2.4。

在服务器本身和所有公司内部客户端上,HTTP 工作正常,HTTPS 工作正常。从 HTTP 重定向到 HTTPS 也能正常工作。

在公司外部的客户端(即家用计算机)上,HTTP 工作正常,HTTPS 工作正常。但是,从 HTTP 重定向到 HTTPS 是错误的。

出现的错误信息如下:ERR_CERT_AUTHORITY_INVALID

发生此错误时,如果我查看证书的详细信息,它们表明证书颁发给“localhost.localdomain”。我没有在我的 Apache 配置文件中找到该域名。详细信息还说证书的组织是我们的互联网服务提供商,于 2011 年 5 月 7 日颁发,并于 2021 年 3 月 4 日到期。这些证书详细信息均与我们的实际证书不符。我们的证书由 Digicert 颁发,将于 2019 年到期。

当我使用 SSL Labs 进行诊断时,测试甚至没有完全运行并出现以下错误消息:

Certificate name mismatch
Try these other domain names (extracted from the certificates):

    localhost.localdomain

这些是我的 VirtualHost 配置:

<VirtualHost *:80>
ServerName www.example.com:80
ServerAlias example.com:80

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^/?(.*)$ https://www.example.com/$1 [NE,L,R=301]
</VirtualHost>


<VirtualHost *:443>
ServerName www.example.com:443
ServerAlias example.com:443
SSLEngine on
SSLCertificateFile "C:\https\star_example_com.crt"
SSLCertificateKeyFile "C:\https\star_example.com.key"
SSLCertificateChainFile "C:\https\DigiCertCA.crt"

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.example.com$ [NC]
RewriteRule ^/?(.*)$ https://www.example.com/$1 [NE,L,R=301]
</VirtualHost>

我也曾尝试使用以下重定向命令进行重定向,但同样的事情发生了:

Redirect permanent / https://www.example.com/

最佳答案

所以,我们想通了。它与 HTTPS 或重定向关系不大。

我们有一个网站故障转移服务器,如果它检测到我们的主站点离线或出现故障,它就会启动。

显然,故障转移逻辑将 301/302 重定向检测为失败。故障转移服务器正在提供神秘证书。

我们必须更改故障转移逻辑以不再将重定向视为失败。

关于apache - 将 HTTP 重定向到 HTTPS 时,HTTPS 在外部客户端上中断,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46712924/

相关文章:

apache - 除了创建符号链接(symbolic link)之外,a2ensite 还能做什么?

java - 多进程监听端口时,tomcat为什么会收到请求?

php - 无法从本地计算机连接到 apache 服务器

ssl - Spring Security,ssl ldap,没有证书

使用 AFNetworking 没有证书的 iOS SSL Pinning?

c - 错误 : 'strdup' was not declared in this scope

ssl - Kafka 架构注册表 - 启动架构注册表时出错 (io.confluence.kafka.schemaregistry.rest.SchemaRegistryRestApplication)

javascript - 如何使用 jQuery 或 Javascript 将按钮重定向到另一个页面

apache - 如何编辑 htaccess 以将所有流量重定向到安全的 www 域

.htaccess:如何使用 .htaccess 使用 no-follow、do-not-index 指令永久重定向动态地址