我有 2 个不同的域my.domain1.com
,my.domain2.com
并且都有上下文名称/app1
,这应该被路由到两个不同的后端框。
这里的问题是服务器my.domain1.com
正在运行VirtualHost _default_:443
和路由。现在我需要配置将请求路由到/app1
服务器。是否有基于域名的条件代理选项。internal01
my.domain2.com
/app1
internal02
请让我知道实现这一目标的最佳方法。
答案1
除非我遗漏了您的描述,否则您基本上只是在描述如何使用虚拟主机。在这种情况下,我可能会设置如下段(我已包含合理的 SSL 配置,因为您提到您当前的设置在端口 443 上运行)
<VirtualHost _default_:443>
ServerAlias my.domain1.com
ProxyPreserveHost on
<location />
allow from all
</location>
ProxyPass /app1 http://internal01/
ProxyPassReverse /app1 http://internal01/
SSLEngine on
SSLProtocol all -SSLv2
SSLCipherSuite ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AES:RSA+3DES:HIGH:!aNULL:!MD5:!DSS
SSLHonorCipherOrder on
SSLCertificateFile /etc/pki/tls/certs/certfordomain1.crt
SSLCertificateKeyFile /etc/pki/tls/private/privatekeyfordomain1.key
SSLCertificateChainFile /etc/pki/tls/certs/chain.pem
SSLCACertificateFile /etc/pki/tls/certs/ca.pem
</VirtualHost>
对于第二台主机:
<VirtualHost _default_:443>
ServerAlias my.domain2.com
ProxyPreserveHost on
<location />
allow from all
</location>
ProxyPass /app1 http://internal02/
ProxyPassReverse /app1 http://internal02/
SSLEngine on
SSLProtocol all -SSLv2
SSLCipherSuite ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AES:RSA+3DES:HIGH:!aNULL:!MD5:!DSS
SSLHonorCipherOrder on
SSLCertificateFile /etc/pki/tls/certs/certfordomain2.crt
SSLCertificateKeyFile /etc/pki/tls/private/privatekeyfordomain2.key
SSLCertificateChainFile /etc/pki/tls/certs/chain.pem
SSLCACertificateFile /etc/pki/tls/certs/ca.pem
</VirtualHost>
希望这可以帮助!