大网数据广告活动
服务器运维问答

What is the use of ProxyPassReverse Directive

· 52CE 我爱测

Definition from apache.org says: This directive lets Apache httpd adjust the URL in the Location, Content-Location and URI headers on HTTP redirect responses. This is essential when Apache httpd is used as a reverse proxy (or gat…

问题原文

原帖链接 · SnowmanOnFire · CC BY-SA 3.0

Definition from apache.org says:

This directive lets Apache httpd adjust the URL in the Location, Content-Location and URI headers on HTTP redirect responses. This is essential when Apache httpd is used as a reverse proxy (or gateway) to avoid bypassing the reverse proxy because of HTTP redirects on the backend servers which stay behind the reverse proxy.

Only the HTTP response headers specifically mentioned above will be rewritten. Apache httpd will not rewrite other response headers, nor will it by default rewrite URL references inside HTML pages. This means that if the proxied content contains absolute URL references, they will bypass the proxy. To rewrite HTML content to match the proxy, you must load and enable mod_proxy_html.

path is the name of a local virtual path; url is a partial URL for the remote server. These parameters are used the same way as for the ProxyPass directive.

Can someone please explain me how it works. In general what does this directive do?

已采纳解答

原帖链接 · Colt · CC BY-SA 3.0

If the server actually handling a request does a redirect to a different URL on that server, the ProxyPassReverse directive rewrites the URL in terms of the reverse proxy server. For example, as noted in the Apache documentation, if:

 http://reverseproxy.com/mirror/foo/bar

is sent (reverse proxied) to

 http://backend.example.com/bar

for handling, but at the backend server it is determined that the correct URL should have been quux, i.e. that the request must be redirected to

 http://backend.example.com/quux

the ProxyPassReverse directive rewrites the URL (at the reverse proxy) to

 http://reverseproxy.com/mirror/foo/quux

before forwarding the HTTP redirect response to the client. This way the client only knows about the reverse proxy server, but can nonetheless make the required request to the correct URL of http://reverseproxy.com/mirror/foo/quux which will then be reverse proxied to the backend server and handled as normal. In short, it just allows the reverse proxy to return correct URI headers on HTTP redirect responses.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-04-30)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。