Skip to content
Serve Nagios 3 as a standalone Apache site

Serve Nagios 3 as a standalone Apache site

Written in 2015 for Nagios 3 and Apache 2.4 on Ubuntu. Commands and paths may be outdated.

By default Nagios 3 is served as an alias, your-domain.com/nagios3. To serve it as a standalone site:

  1. Disable the default config: a2disconf nagios3

  2. Link the Nagios Apache config as a site: ln -s /etc/nagios3/apache2.conf /etc/apache2/sites-enabled/your-domain.com.conf

  3. Edit that file to look like this:

    <VirtualHost *:80>
            ServerAdmin webmaster@example.com
            ServerName nagios.example.com
    
            ScriptAlias /cgi-bin/nagios3 /usr/lib/cgi-bin/nagios3/
    
            Alias /stylesheets /etc/nagios3/stylesheets/
            Alias / /usr/share/nagios3/htdocs/
    
            DocumentRoot /usr/share/nagios3/htdocs/
    
            <DirectoryMatch (/usr/share/nagios3/htdocs|/usr/lib/cgi-bin/nagios3|/etc/nagios3/stylesheets)>
                    Options FollowSymLinks
    
                    DirectoryIndex index.php index.html
    
                    AllowOverride AuthConfig
                    Order Allow,Deny
                    Allow From All
    
                    AuthName "Nagios Access"
                    AuthType Basic
                    AuthUserFile /path/to/nagios3/htpasswd.users
                    require valid-user
            </DirectoryMatch>
    
            <Directory /usr/share/nagios3/htdocs>
                    Options +ExecCGI
            </Directory>
    
            ErrorLog ${APACHE_LOG_DIR}/nagios.example.com-error.log
            LogLevel warn
            CustomLog ${APACHE_LOG_DIR}/nagios.example.com-access.log combined
    </VirtualHost>
  4. In /etc/nagios3/cgi.cfg, change url_html_path from /nagios3 to /.

  5. Restart Apache: service apache2 restart

Last updated on