1

I'm using Apache and mod_proxy to provide access to the Monit GUI over HTTP. So far my configuration is as follows:

    ProxyRequests Off
    <Proxy *>
            Order deny,allow
            Allow from all
    </Proxy>
    ProxyPreserveHost on
    ProxyPass /monit http://localhost:2812/
    ProxyPassReverse /monit http://localhost:2812/

When people go to http://mywebsite/monit they do get the Monit home page. However the links returned by Monit have an absolute path, which breaks the proxy which is only applied to paths starting with /monit. I could create a separate vhost just for Monit (e.g. http://monit.mywebsite) which would fix the problem, but was wondering if there was another solution.

Q1: Is there a way to get Apache to rewrite links in HTML code to prepend whatever path is defined in the ProxyPass and ProxyPassReverse directive?

Q2: If above not possible, do you see another solution than the separate vhost I **mentioned?

Max
  • 3,373
  • 15
  • 51
  • 71

1 Answers1

0

EDIT

Your proxy setup is slightly incorrect:

it should be:

ProxyRequests Off
<Proxy *>
        Order deny,allow
        Allow from all
</Proxy>
ProxyPreserveHost on
ProxyPass /monit http://localhost:2812
ProxyPassReverse /monit http://localhost:2812

notice the difference? In your setup you remove a / to many.

you could also go for

ProxyPass /monit/ http://localhost:2812/
ProxyPassReverse/ /monit http://localhost:2812/

but then requests to http://mywebsite/monit would not work, only to http://mywebsite/monit/ which would be kind of inconvenient.


OLD Response

Probably mod_proxy_html could do what you want but as far as I know it's never the best solution.... I don't know Monit but isn't there an option in it to make it only use relative paths?

Marcel G
  • 2,149
  • 14
  • 24