问题原文
原帖链接 · Lunartist · CC BY-SA 4.0
The official document states that:
The
ProxyPassconfigures the server to fetch the appropriate documents, while theProxyPassReversedirective rewrites redirects originating atinternal.example.comso that they target the appropriate directory on the local server.
From that I understand that ProxyPassReverse rewrites the header. But why do you need ProxyPass for? Why isn't ProxyPassReverse itself enough? What exactly does ProxyPass do?
已采纳解答
原帖链接 · Stephen Ostermiller · CC BY-SA 4.0
ProxyPass by itself enables the reverse proxy functionality and in some cases that is enough. For example ProxyPass / http://localhost:8080/ configures Apache to proxy the site from a back end server.
This works pretty well until the back end wants to issue redirects. Redirects have to be to fully qualified absolute URLs. To redirect /foo to /bar the back end would respond with a redirect response with Location: http://localhost:8080/bar. If that got proxied directly to the client, the redirect would break.
One solution to this problem would be to reconfigure the back end to know that it is serving http://mysite.example and not http://localhost:8080. Then it could use the correct absolute redirects. This could even be done dynamically by having the back end examine X-Forwarded-For headers that tell it when it is behind a reverse proxy or send the Host: header to the backend with ProxyPreserveHost.
However, not all back ends support such configuration. If not you can use the ProxyPassReverse directive to change the Location header on the response. That configuration only exists to fix broken redirects from the back end.
Similarly ProxyPassReverseCookieDomain is meant to fix when the back end tries to set cookies for the wrong domain. You can even install mod_proxy_html to parse all the HTML from the back end and fix any absolute links within the HTML documents.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
