diff --git a/core/service.go b/core/service.go index 928940cb..b0c09b97 100644 --- a/core/service.go +++ b/core/service.go @@ -14,6 +14,11 @@ import ( "github.com/TwinProduction/gatus/client" ) +const ( + // HostHeader is the name of the header used to specify the host + HostHeader = "Host" +) + var ( // ErrServiceWithNoCondition is the error with which gatus will panic if a service is configured with no conditions ErrServiceWithNoCondition = errors.New("you must specify at least one condition per service") @@ -216,6 +221,9 @@ func (service *Service) buildHTTPRequest() *http.Request { request, _ := http.NewRequest(service.Method, service.URL, bodyBuffer) for k, v := range service.Headers { request.Header.Set(k, v) + if k == HostHeader { + request.Host = v + } } return request } diff --git a/core/service_test.go b/core/service_test.go index ba0a5d33..893a2788 100644 --- a/core/service_test.go +++ b/core/service_test.go @@ -96,6 +96,9 @@ func TestService_GetAlertsTriggered(t *testing.T) { URL: "https://twinnation.org/health", Conditions: []*Condition{&condition}, Alerts: []*Alert{{Type: PagerDutyAlert, Enabled: true}}, + Headers: map[string]string{ + "Host": "twinnation.org", + }, } service.ValidateAndSetDefaults() if service.NumberOfFailuresInARow != 0 {