Proxypass 指令是否需要 ProxyPassReverse 指令?

the*_*cer 20 mod-proxy apache-2.2

是否所有 ProxyPass 指令都需要 ProxyPassReverse 指令?

ProxyPass / http://foo.example.com:8080/  
ProxyPassReverse / http://www.example.com/
Run Code Online (Sandbox Code Playgroud)

我看到了这个片段,并了解到所有流量都foo.example.com被代理到 foo.example.com:8080。第二行有什么作用?

alv*_*osu 15

该指令允许 Apache 调整 HTTP 重定向响应的 Location、Content-Location 和 URI 标头中的 URL

例如,假设本地服务器的地址为http://example.com/;然后

ProxyPass /mirror/foo/ http://backend.example.com/
ProxyPassReverse /mirror/foo/ http://backend.example.com/
ProxyPassReverseCookieDomain backend.example.com public.example.com
ProxyPassReverseCookiePath / /mirror/foo/
Run Code Online (Sandbox Code Playgroud)

不仅会导致对http://example.com/mirror/foo/bar的本地请求在内部转换为对http://backend.example.com/bar的代理请求(ProxyPass 在这里提供的功能)。它还负责重定向服务器 backend.example.com 发送:当http://backend.example.com/bar被他重定向到http://backend.example.com/quux Apache 将其调整为http:/ /example.com/mirror/foo/quux在将 HTTP 重定向响应转发给客户端之前。请注意,用于构建 URL 的主机名是根据 UseCanonicalName 指令的设置选择的。