我有2个apache 2.4 serverA和serverB有几个virtualhost。所有传入的请求都到达服务器A.
如何将特定虚拟主机名的http和https请求从serverA转发到serverB?
我的wamp ServerA设置是: 进入我的主机文件 127.0.0.7 example.com
虚拟主机:
<VirtualHost *:*>
ServerName example.com
ProxyPreserveHost On
ProxyPass "/" "http://192.168.1.105/"
ProxyPassReverse "/" "http://192.168.1.105/"
</VirtualHost>
我的serverB ip是192.168.1.105,我在其上设置了一个名为example.com的虚拟主机
当我使用http://example.com
时,我会留在wamp主页上http://localhost
当我使用https://example.com
时,我在serverA上有错误403(禁止)
答案 0 :(得分:0)
Redirect / https://serverb.examample.com/
答案 1 :(得分:0)
经过漫长的一夜,我找到了解决方案:
<VirtualHost *:80>
ProxyPreserveHost On
ProxyPass "/" "http://192.168.1.105/"
ProxyPassReverse "/" "http://192.168.1.105/"
ServerName example.com
</VirtualHost>
<VirtualHost *:443>
SSLProxyEngine on
SSLCertificateFile "${APACHE_DIR}/conf/ssl_example.com/server.crt"
SSLCertificateKeyFile "${APACHE_DIR}/conf/ssl_example.com/server.key"
ErrorLog "logs/example.com-ssl_error.log"
CustomLog "logs/example.com-ssl_access.log" common
ProxyPreserveHost On
ProxyPass "/" "https://192.168.1.105/"
ProxyPassReverse "/" "https://192.168.1.105/"
ServerName example.com
</VirtualHost>