如何确定Apache是​​用作正向代理还是反向代理?

时间:2014-08-30 16:43:06

标签: apache proxy webserver reverse-proxy

Apache可用作正向代理反向代理,如何确定Apache是​​用作正向代理还是反向代理?我认为它在httpd.conf文件中被包含,但我不知道哪个配置字段决定了这一点。

1 个答案:

答案 0 :(得分:1)

ProxyPass和ProxyPassReverse是需要配置为将Apache设置为反向代理的指令。

简单来说,代理通行证'执行从外部到内部的单向地址空间转换,如:

ProxyPass       /app1/  http://internal1.example.com/
ProxyPass       /app2/  http://internal2.example.com/

所以http://www.example.com/app1/some-path会根据需要映射到http://internal1.example.com/some-path

而ProxyPassReverse执行从app / web -server响应到外部地址空间的反向转换,如下所示:

ProxyPassReverse /app1/ http://internal1.example.com/
ProxyPassReverse /app2/ http://internal2.example.com/

这使得对其他内部服务器的自引用/引用不会按原样传递,而是在重定向的情况下转换为外部地址空间,例如:

    HTTP/1.1 302 Found  
    Location: http://internal.example.com/foo/         
 //ProxyPass lets this through to user browser as-is!

使用反向代理服务器将其作为

返回给用户的浏览器
  HTTP/1.1 302 Found
  Location: http://www.example.com/foo/

使用ProxyPassReverse指令。

相关问题