Load Balancer health check on VM (running Apache2 on Ubuntu) works fine when path is set to '/'. Health Check is pretty simple over HTTP on port 80. Load Balancer and VM communicate over HTTP:80 and external requests on HTTP are redirtected to HTTPS with 301 response if
RewriteCond %{HTTP:X-Forwarded-Proto} =http
As this is the home page of the app and little heavy on content, I decided to move health check to some other html page which is light to process. In other words I updated Path from '/' to '/some-dir/some-page.html' After doing this health check fails. There are many similar questions but none of them is helpful in this case. It might be that 301 response from VM might fail the health check but it works for '/'. Why health check fails if Path is updated? Strangely, same health check ('/' to '/some-dir/some-page.html') when applied to unmanaged Instance Group works pretty well. Any help would be appreciated.
Health Check details -
$ gcloud compute health-checks describe health-check-name
checkIntervalSec: 5
creationTimestamp: '2023-06-01T19:21:19.177-07:00'
description: ''
healthyThreshold: 2
httpHealthCheck:
host: ''
port: 80
proxyHeader: NONE
requestPath: /some-dir/some-page.html
id: '7467560598743870704'
kind: compute#healthCheck
logConfig:
enable: false
name: dp-instance-heartbeat-check-exclude-home
selfLink: https://www.googleapis.com/compute/v1/projects/
project-name/global/healthChecks/health-check-name
timeoutSec: 5
type: HTTP
unhealthyThreshold: 2
result of curl -v example.com/some-dir/some-page.html
StatusCode : 200
StatusDescription : OK
Content : <!DOCTYPE HTML>...
RawContent : HTTP/1.1 200 OK
Pragma: no-cache...
Forms : {}
Headers : {[Pragma, no-cache], [Cache-Control,...}
ParsedHtml : mshtml.HTMLDocumentClass
.....
RawContentLength : 114051