Applications Systems

HTTPS monitor returns error code in SAM

Learn how to resolve issue with the HTTPS monitor returning error code 401 or 403

First published date

5/15/2019 9:24 PM

Last published date

5/15/2019 9:24 PM

Overview

The HTTPS monitor returns error code 401 or 403

Product section

Server Application Monitor

Cause

More than one website can run on the same public IP address.

Example:
https://thisisanexamp.le - opens correctly in the browser

HTTPS monitor resolves the IP address of the website and tries to open https://xxx.xxx.xxx.xxx
Which returns:
"Our services aren't available right now</h2><p>We're working to restore all services as soon as possible. Please check back soon."
or:
"403 Forbidden"
or:
"401 Unauthorized"

Resolution

Create Windows Powershell Monitor, add the script below and adjust the url
 
$url=("https://your_url_comes_here")

$wsc=(Invoke-WebRequest -UseBasicParsing -Uri $url).statuscode

try { $response = Invoke-WebRequest $url } catch {

      $_.Exception.Response.StatusCode.Value__}

If ( $wsc -ne "200" )

{

   Write-Host "Statistic: 1"

Write-Host "Message: $wsc"
   exit 1

}

Else

{

   Write-Host "Statistic: 0"
Write-Host "Message: $wsc"

   exit 0

}