JasonRivers / Docker-Nagios

Docker image for Nagios
MIT License
233 stars 254 forks source link

Nagiosgraph not accessible if using proxy #63

Closed cathode911 closed 6 years ago

cathode911 commented 6 years ago

Hey, thanks for the awesome container! It's working great, although i found a minor issue with nagiosgraph.

I run nagios container through nginx proxy with url https://mysrv.domain.com/nagios4/ and although nagios works fine with proxy - nagiosgraph shows 404 as its urls are https://mysrv.domain.com/cgi-bin..... I guess they are static.

JasonRivers commented 6 years ago

Sorry for the delay, This is configurable in your Nagios config. I use a template for services I wish to graph, this looks like the following:

define service {
        name                            graphed-service
        action_url                      /cgi-bin/show.cgi?host=$HOSTNAME$&service=$SERVICEDESC$' onMouseOver='showGraphPopup(this)' onMouseOut='hideGraphPopup()' rel='/cgi-bin/showgraph.cgi?host=$HOSTNAME$&service=$SERVICEDESC$&period=day&rrdopts=-w+450+-j
        register                        0
}

and then my service template does the following:

define service {
        name                            ICMPv4-Template
        use                             service-global,graphed-service
        service_description             ICMPv4
        check_command                   check_ping!-4 -H $HOSTADDRESS$ -w 80.0,10% -c 100.0,20%
        check_interval                  1
        register                        0
}

On the graphed-service, you can change the URL to be anything you want, you could even use grafana or similar if you wanted.

Hopefully this fixes the issue, Alternatively in your proxy under NGINX you could forward /cgi-bin to /nagios4/cgi-bin, something like:

location /cgi-bin/ {
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_pass http://nagioscontainer/cgi-bin;
}

Let me know how you get on.

cathode911 commented 6 years ago

Jason, I have tested your approach and it works like a charm! Thank you for you help and for the great container, saves me loads of time ;)