{"id":3728,"date":"2023-04-27T13:08:09","date_gmt":"2023-04-27T13:08:09","guid":{"rendered":"https:\/\/geekmungus.co.uk\/?p=3728"},"modified":"2023-04-27T13:08:09","modified_gmt":"2023-04-27T13:08:09","slug":"check_http-gives-403-forbidden-error-monitoring-site-via-aws-application-load-balancer-alb","status":"publish","type":"post","link":"https:\/\/geekmungus.co.uk\/?p=3728","title":{"rendered":"check_http Gives 403 Forbidden Error Monitoring Site via AWS Application Load Balancer (ALB)"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">We&#8217;ve started to host websites on AWS, we want to monitor using NagiosXI, but we got some odd results when first attempting to. The web application has no &#8220;index.html&#8221; page, which is one cause of the 403 forbidden error. However we were getting the same thing even when specifying the correct path. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It turns out there are a few things at play here, one I mention in <a rel=\"noreferrer noopener\" href=\"https:\/\/geekmungus.co.uk\/?p=1289\" target=\"_blank\">https:\/\/geekmungus.co.uk\/?p=1289<\/a> this relates to the SNI which can be required when there are multiple sites (with different SSL Certificates) hosted on the same IP:Port which is the case with an ALB or any load balancer to a certain extent. The other key thing is that your NagiosXI poll must look like a normal request, or the load balancer won&#8217;t interpret it correctly.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In our case however it was the WAF that was the problem, it was seeing the request as a BOT because the Nagios request did not provide a UserAgent string! To resolve this you&#8217;d do something like:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.\/check_http -H www.mysite.com --sni --hostname=www.mysite.com -u \/ --useragent=\"Mozilla\/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko\/20100101 Firefox\/112.0\" -f follow -S\r\nHTTP OK: HTTP\/1.1 200 OK - 7589 bytes in 0.088 second response time |time=0.088117s;;;0.000000 size=7589B;;;0\r\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Adding in an valid UserAgent string solved the issue.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We&#8217;ve started to host websites on AWS, we want to monitor using NagiosXI, but we got some odd results when first attempting to. The web application has no &#8220;index.html&#8221; page, which is one cause of the 403 forbidden error. However we were getting the same thing even when specifying the correct path. It turns out &#8230; <a title=\"check_http Gives 403 Forbidden Error Monitoring Site via AWS Application Load Balancer (ALB)\" class=\"read-more\" href=\"https:\/\/geekmungus.co.uk\/?p=3728\" aria-label=\"Read more about check_http Gives 403 Forbidden Error Monitoring Site via AWS Application Load Balancer (ALB)\">Read more<\/a><\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,16],"tags":[],"class_list":["post-3728","post","type-post","status-publish","format-standard","hentry","category-cloud","category-nagios-and-nagiosxi"],"_links":{"self":[{"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/3728","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3728"}],"version-history":[{"count":2,"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/3728\/revisions"}],"predecessor-version":[{"id":3730,"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/3728\/revisions\/3730"}],"wp:attachment":[{"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3728"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3728"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3728"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}