ssl - 为什么所有 SSL 子域都指向同一个 IP

标签 ssl proxy apache2 virtualhost reverse-proxy

我将我的 apache 服务器设置为充当两个服务的反向代理。一个在 192.168.1.50:5000 上运行,另一个在 192.168.1.121:8989 上运行。

我希望 https://apple.example.com 转到 192.168.1.50:5000https://orange.example.com 转到 192.168.1.121:8989

apple.example.com 按预期工作,但出于某种原因,当我启用两个站点时,每当我尝试加载 orange.example.com 时加载 apple 并且地址 Chrome 是 https://apple.example.com。如果我禁用 apple 虚拟主机,orange 会按预期工作

这是我的两个虚拟主机:

<VirtualHost *:443>
    ProxyPreserveHost On
    ProxyRequests Off
    ServerName apple.example.com
    ServerAlias www.apple.example.com
    ProxyPass / http://192.168.1.50:5000/
    ProxyPassReverse / http://192.168.1.50:5000/    

    <Location />
        SSLRequireSSL
        Order allow,deny
        Allow from all
    </Location>

    SSLEngine On
    SSLProxyEngine On
    SSLCertificateFile /etc/apache2/ssl/apache.crt
    SSLCertificateKeyFile /etc/apache2/ssl/apache.key
</VirtualHost>

<VirtualHost *:80>
    ServerName apple.example.com
    ServerAlias www.apple.example.com
    Redirect permanent / https://apple.example.com/
</VirtualHost>

<VirtualHost *:443>
    ProxyPreserveHost On
    ProxyRequests Off
    ServerName orange.example.com
    ServerAlias www.orange.example.com
    ProxyPass / http://192.168.1.121:8989/
    ProxyPassReverse / http://192.168.1.121:8989/   

    <Location />
        SSLRequireSSL
        Order allow,deny
        Allow from all
    </Location>

    SSLEngine On
    SSLCertificateFile /etc/apache2/ssl/apache.crt
    SSLCertificateKeyFile /etc/apache2/ssl/apache.key
</VirtualHost>

<VirtualHost *:80>
    ServerName orange.example.com
    ServerAlias www.orange.example.com
    Redirect permanent / https://orange.example.com/
</VirtualHost>

最佳答案

在尝试解决这个问题大约 2 小时后,我意识到因为我的重定向是永久性的,所以它被缓存在 Chrome 中。在某些时候,我的浏览器一定存储了从 orangeapple 的永久重定向。当我意识到转到 https://orange.example.com 有效但 http://apple.example.com 会重定向到 时,我明白了这一点苹果。清除浏览器缓存后,它运行良好。非常令人沮丧。

关于ssl - 为什么所有 SSL 子域都指向同一个 IP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32259050/

相关文章:

ssl - 如何在 openssl 1.0.2g 中列出 TLS 1.2 密码套件

node.js - 使用 Node.js 将 http 重定向到 https

使用 SSL IP 重写 Apache

proxy - 无法使用 Charles Web 代理作为反向代理接收和转发远程请求

Apache : Using SSL with j_security_check 背后的 Tomcat

ssl - 如何在新的 Apache Http Client 4.3 中创建 SSL 套接字工厂?

nginx - 如何使用 nginx 1.9.5 作为 gRPC 的反向代理?

java - 阻止或允许带有 "/etc/hosts"的网站真的已被弃用吗?用什么代替?

html - Twitter 卡片预览无法获取我的图像

PHP mail() 无法发送邮件 |后缀配置 | Apache 2 | Ubuntu 16.04