Setup monit behind Apache proxy under ISPConfig

Today I wanted to setup monit behind Apache proxy on my webserver, which runs ISPConfig (https://www.ispconfig.org/) under Debian. Monit is a OpenSource monitoring tool for Linux (see https://mmonit.com/monit/).

Requirements

I had the following requirements on the solution:

  • monit should only be accessible from the server itself (localhost)
  • monit should run under a special SSL-secured URL (not IP:PORT as in default)
  • monit should run password protected
set httpd port 2812 and
use address 127.0.0.1 # bind to loopback only
allow localhost       # allow only localhost to connect to the server and
allow ask:sheldon     # require user 'ask' and password 'sheldon'

Software Versions

  • Debian 3.16.39-1 (2016-12-30) x86_64 GNU/Linux
  • ISPConfig 1.3.2
  • Apache 2.4.10 (Debian)
  • Monit version 5.20.0

Steps to setup monit behind Apache proxy

  1. First I had to login as root. But sudo-ing with a sudoers user should work as well.
  2. Install monit:
    $> apt-get install monit
    $> service monit start
  3. Add a new config file under /etc/monit/conf.d/ask-sheldon.cfg with the following content:
    set httpd port 2812 and
    use address 127.0.0.1 # bind to loopback only
    allow localhost       # allow only localhost to connect to the server and
    allow ask:sheldon     # require user 'ask' and password 'sheldon'
  4. Setup a subdomain monitoring.ask-sheldon.com as a new website (sites tab in ISPConfig) with Let’s Encrypt (https://letsencrypt.org/) as SSL-maintainer and such stuff.
  5. Enabled http-proxy module for Apache:
    $> a2enmod proxy_http
    $> service apache2 restart

     

  6. Add the proxy definition to the Apache directives in ISPConfig:
    ProxyPass /monit/ http://127.0.0.1:2812/ 
    ProxyPassReverse /monit/ http://127.0.0.1:2812/ 
    <Location /monit/>
        Order deny,allow
        Allow from all
        ProxyPassReverseCookiePath / /monit/
    </Location>

     

    The Apache directives can be found in the site administration of the respective website in the options tab as shown below.

    Setup monit behind Apache proxy - Apache directives

 

That’s it! That’s how I setup monit behind Apache proxy. Now I was able to call monit via the following URL in webbrowser:

https://monitoring.ask-sheldon.com/monit/

Finally I put this URL together with the given credentials to the server configuration of ISPConfig (System Tab -> Server Config):

Setup monit behind Apache proxy - Server Config

Afterwards the monit monitoring can be seen in ISPConfig backend (Monitor Tab -> Show Monit)
Setup monit behind Apache proxy - Monit

Leave a Reply

Your email address will not be published. Required fields are marked *

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.