Ad Widget

Collapse

Nginx Template - Status page 403

Collapse
This topic has been answered.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ESITGuy
    Junior Member
    • Mar 2023
    • 17

    #1

    Nginx Template - Status page 403

    Failed to fetch stub status page:
    HTTP/1.1 403 Forbidden
    Connection: close
    Content-Length: 162
    Content-Type: text/html
    Date: Thu, 11 Jul 2024 02:01:59 GMT
    Server: nginx/1.18.0 (Ubuntu)
    <html>
    <head><title>403 Forbidden</title></head>
    <body>
    <center><h1>403 Forbidden</h1></center>
    <hr><center>nginx/1.18.0 (Ubuntu)</center>
    </body>
    </html>

    Curling from the server to the destination results in what I would expect.
    curl -i http://ipaddress:10059/basic_status
    HTTP/1.1 200 OK
    Server: nginx/1.18.0 (Ubuntu)
    Date: Thu, 11 Jul 2024 02:05:36 GMT
    Content-Type: text/plain
    Content-Length: 106
    Connection: keep-alive

    Active connections: 5
    server accepts handled requests
    1205 1205 3732
    Reading: 0 Writing: 1 Waiting: 0

    ​​​What am I missing here?
  • Answer selected by ESITGuy at 16-10-2024, 22:01.
    ESITGuy
    Junior Member
    • Mar 2023
    • 17

    Yip, that was it. I was approaching it from the wrong place. This is a query from the agent to nginx, not the Zabbix server to Nginx. All makes sense when you say it outload huh? For anyone who finds themselves in the same pickle:

    Nginx HTTP server block:
    server {
    listen 127.0.0.1:PORTNUMBER;
    server_name localhost;

    location /basic_status {
    stub_status;
    allow 127.0.0.1;
    deny all;
    }
    }

    In my example I've chosen not to use port 80 (I'm sure I'll thank myself later, this being a webserver and all)

    Edited the {$NGINX.STUB_STATUS.PORT} macro for the template to my chosen port. {$NGINX.STUB_STATUS.HOST} is set to 127.0.0.1, I guess this could also be localhost but I haven't tested that.

    Comment

    • Hamardaban
      Senior Member
      Zabbix Certified SpecialistZabbix Certified Professional
      • May 2019
      • 2713

      #2
      What type of item are you using?
      Are you accessing different ip addresses or different urls?
      Also check the nginx configuration settings - is there an access control setting for the status page?

      Comment

      • ESITGuy
        Junior Member
        • Mar 2023
        • 17

        #3
        1. I don't think I understand the question. I'm using the default Nginx by Zabbix agent. I've changed {$NGINX.STUB_STATUS.PORT} to the port required, and {$NGINX.STUB_STATUS.HOST} from localhost to the IP of the host running Nginx.
        2. As above, they appear to be set fine otherwise it wouldn't give me a 403. 403 is a response Nginx, just not the one I need. If I put an erroneous IP I get: Cannot get content of web page: Get "http://xx.xx.xx.xx:10059/basic_status": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
        3. Yes there are ACL's in place, the Zabbix server is one of the "allowed". As in my first post, running a query from the Zabbix server to the webserver returns a positive result.

        I have just discovered, running http://xx.xx.xx.xx:10059/basic_status from the webserver itself returns 403. I was running with 127.0.0.1 and the IP of the webserver in the ACL and still no result. Looks like I've been looking in the wrong place, I need to test from the agent to the webserver, not Zabbix to the webserver.

        Comment

        • ESITGuy
          Junior Member
          • Mar 2023
          • 17

          #4
          Yip, that was it. I was approaching it from the wrong place. This is a query from the agent to nginx, not the Zabbix server to Nginx. All makes sense when you say it outload huh? For anyone who finds themselves in the same pickle:

          Nginx HTTP server block:
          server {
          listen 127.0.0.1:PORTNUMBER;
          server_name localhost;

          location /basic_status {
          stub_status;
          allow 127.0.0.1;
          deny all;
          }
          }

          In my example I've chosen not to use port 80 (I'm sure I'll thank myself later, this being a webserver and all)

          Edited the {$NGINX.STUB_STATUS.PORT} macro for the template to my chosen port. {$NGINX.STUB_STATUS.HOST} is set to 127.0.0.1, I guess this could also be localhost but I haven't tested that.

          Comment

          • Hamardaban
            Senior Member
            Zabbix Certified SpecialistZabbix Certified Professional
            • May 2019
            • 2713

            #5
            That's it! This is what my question about the type of item was directed at - they connect from different places.

            Comment

            Working...