GregB
GregB

Reputation: 5725

Can Apache rewrite ports in the URI?

I've setup a basic proxy for a Cassandra monitoring tool that Datastax wrote called OpsCenter. The app is a python webserver that listens on 8888/8443. The app doesn't run as root, so it can't bind on 80/443, so I want to run Apache in front as a proxy/reverse proxy. The problem I'm running into is that OpsCenter rewrites the URI after each requests, and writes the port.

e.g. https://mydomain.com/ becomes https://mydomain.com:8443/ after each request. This prevents all future requests from working because 8443 isn't open on the firewall.

Can Apache remove the port from the URI when returning the response to the client?

Here's what my proxy config looks like. I'm doing SSL termination at the Proxy.

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

Upvotes: 1

Views: 284

Answers (2)

Reiner030
Reiner030

Reputation: 20

  • you can set

    ProxyPreserveHost Off
    
  • or if you want let it (as me) with:

    ProxyPreserveHost On
    

    then you must rewrite it this way:

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

Upvotes: 0

Peter Halliday
Peter Halliday

Reputation: 301

If you change opscenterd.conf, which for packages is at /etc/opscenter/opscenterd.conf, you can set the port that is listed to, and therefore what it rewrites to as

[webserver]
port = 8888
interface = 0.0.0.0

This will require that the ports that you are binding to aren't already being used by another process.

Upvotes: 1

Related Questions