Apache 反向代理失败,apache代理失败


公司apache配置的反向代理,对本地server成功,对远程server失败。

例如下面的配置是成功的

ProxyPass        /service/xis https://localhost:8080/v1/xis
ProxyPassReverse /service/xis https://localhost:8080/v1/xis

但是当被代理的server改成远程server时失败

ProxyPass        /service/xis  https://api-dev.test.com/v1/xis
ProxyPassReverse /service/xis  https://api-dev.test.com/v1/xis

问题的原因是因为 ProxyPreserveHost 参数设置造成的

ProxyPreserveHost on 时会用当前server的host替换 被代理服务器的hostname。

所以要代理远程服务器必须把 ProxyPreserveHost 设为 off

<Location /service/xis>
    ProxyPreserveHost Off
    ProxyPass https://api-dev.test.com/v1/xis
    ProxyPassReverse https://api-dev.test.com/v1/xis
</Location>

相关内容

    暂无相关文章