【问题标题】:How to determine whether Apache is using as Forward Proxy or Reverse Proxy?如何确定 Apache 是用作正向代理还是反向代理?
【发布时间】:2024-04-22 14:40:01
【问题描述】:

Apache可以用作Forward ProxyReverse Proxy,如何判断Apache是​​用作Forward Proxy还是Reverse Proxy?我认为它是在httpd.conf 文件中配置的,但我不知道是哪个配置字段决定的。

【问题讨论】:

    标签: apache proxy webserver reverse-proxy


    【解决方案1】:

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

    简单来说,“ProxyPass”执行从外部到内部的单向地址空间转换,如下所示:

    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 服务器响应到外部地址空间的反向转换,如下所示:

    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 指令。

    【讨论】: