【问题标题】:Can Apache rewrite ports in the URI?Apache 可以重写 URI 中的端口吗?
【发布时间】:2013-12-11 18:09:02
【问题描述】:

我已经为 Datastax 编写的名为 OpsCenter 的 Cassandra 监控工具设置了一个基本代理。该应用程序是一个侦听 8888/8443 的 python 网络服务器。该应用程序不以 root 身份运行,因此无法在 80/443 上绑定,所以我想在前面运行 Apache 作为代理/反向代理。我遇到的问题是 OpsCenter 在每次请求后重写 URI,并写入端口。

例如https://mydomain.com/ 在每次请求后变为 https://mydomain.com:8443/。这会阻止所有未来的请求,因为 8443 未在防火墙上打开。

Apache 在向客户端返回响应时可以从 URI 中删除端口吗?

这是我的代理配置的样子。我正在代理服务器上终止 SSL。

ProxyRequests Off
ProxyPreserveHost On  # OpsCenter also rewrites the host, which becomes 127.0.0.1 without this.
SSLEngine On
SSLProxyEngine On
SSLCertificateFile "/path/to/cert"
SSLCertificateKeyFile "/path/to/key"
SSLProxyCheckPeerCN  Off
SSLProxyCheckPeerExpire Off


ProxyPass /tcp http://127.0.0.1:8888/tcp
ProxyPassReverse /tcp http://127.0.0.1:8888/tcp
ProxyPass /opscenter http://127.0.0.1:8888
ProxyPassReverse /opscenter http://127.0.0.1:8888

【问题讨论】:

    标签: apache datastax-enterprise opscenter


    【解决方案1】:

    如果您更改 opscenterd.conf,对于软件包,它位于 /etc/opscenter/opscenterd.conf,您可以设置列出的端口,以及它重写的内容

    [webserver]
    port = 8888
    interface = 0.0.0.0
    

    这将要求您绑定的端口尚未被其他进程使用。

    【讨论】:

      【解决方案2】:
      • 你可以设置

        ProxyPreserveHost Off
        
      • 或者如果你想让它(像我一样):

        ProxyPreserveHost On
        

        那么你必须这样重写它:

        ProxyPass           /    http://127.0.0.1:8888/
        ProxyPassReverse    /    http://127.0.0.1:8888/
        ProxyPassReverse    /    http://example.com:8888/
        

      【讨论】:

        猜你喜欢
        • 2012-05-28
        • 2012-10-08
        • 2015-10-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-03-05
        • 2016-11-15
        • 1970-01-01
        相关资源
        最近更新 更多