diff --git a/core/core.go b/core/core.go index b46eea5..4fdc3ec 100644 --- a/core/core.go +++ b/core/core.go @@ -74,6 +74,14 @@ type ( Targets []string `json:"targets"` // ips of servers - ["http://127.0.0.1:8080/app1","http://127.0.0.2"] (optional) FwdPath string `json:"fwdpath"` // path to forward to targets - "/goadmin" incoming req: test.com/admin -> 127.0.0.1/goadmin (optional) Page string `json:"page"` // page to serve instead of routing to targets - "We are fixing it" (optional) + // defines health check + Endpoint string `json:"endpoint"` // url path to check for health (todo: what to do when fwdpath is set) (non blank enables health checks) + ExpectedCode int `json:"expected_code"` // expected http response code (default 200) + ExpectedBody string `json:"expected_body"` // expected body + ExpectedHeader string `json:"expected_header"` // expected http header (field:value) + Host string `json:"host"` // 'host' header to use when performing health check + Timeout int `json:"timeout"` // milliseconds before connection times out (default 3000 (3s)) + Attempts int `json:"attempts"` // number of times to try before marking dead } CertBundle struct { diff --git a/proxymgr/nanobox.go b/proxymgr/nanobox.go index 3f6fc00..ac1f530 100644 --- a/proxymgr/nanobox.go +++ b/proxymgr/nanobox.go @@ -33,6 +33,9 @@ func (self Nanobox) Init() error { } config.Log.Info("Proxy listening at https://%s...", config.RouteTls) + // start proxy health checker (todo: make check interval(pulse) configurable) + go router.StartHealth(20) + return nil } @@ -128,7 +131,21 @@ func (self Nanobox) keysToC(certs []router.KeyPair) []core.CertBundle { func (self Nanobox) rToRoutes(routes []core.Route) []router.Route { var rts []router.Route for i := range routes { - rts = append(rts, router.Route{SubDomain: routes[i].SubDomain, Domain: routes[i].Domain, Path: routes[i].Path, Targets: routes[i].Targets, FwdPath: routes[i].FwdPath, Page: routes[i].Page}) + rts = append(rts, router.Route{ + SubDomain: routes[i].SubDomain, + Domain: routes[i].Domain, + Path: routes[i].Path, + Targets: routes[i].Targets, + FwdPath: routes[i].FwdPath, + Page: routes[i].Page, + Endpoint: routes[i].Endpoint, + ExpectedCode: routes[i].ExpectedCode, + ExpectedBody: routes[i].ExpectedBody, + ExpectedHeader: routes[i].ExpectedHeader, + Host: routes[i].Host, + Timeout: routes[i].Timeout, + Attempts: routes[i].Attempts, + }) } return rts } @@ -136,7 +153,21 @@ func (self Nanobox) rToRoutes(routes []core.Route) []router.Route { func (self Nanobox) routesToR(routes []router.Route) []core.Route { var rts []core.Route for i := range routes { - rts = append(rts, core.Route{SubDomain: routes[i].SubDomain, Domain: routes[i].Domain, Path: routes[i].Path, Targets: routes[i].Targets, FwdPath: routes[i].FwdPath, Page: routes[i].Page}) + rts = append(rts, core.Route{ + SubDomain: routes[i].SubDomain, + Domain: routes[i].Domain, + Path: routes[i].Path, + Targets: routes[i].Targets, + FwdPath: routes[i].FwdPath, + Page: routes[i].Page, + Endpoint: routes[i].Endpoint, + ExpectedCode: routes[i].ExpectedCode, + ExpectedBody: routes[i].ExpectedBody, + ExpectedHeader: routes[i].ExpectedHeader, + Host: routes[i].Host, + Timeout: routes[i].Timeout, + Attempts: routes[i].Attempts, + }) } return rts } diff --git a/vendor/vendor.json b/vendor/vendor.json index 4ad4250..881c0b1 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -159,10 +159,10 @@ "revisionTime": "2017-03-27T21:44:30Z" }, { - "checksumSHA1": "0J1NLSmuczwouZtUqEuPxLTuPRA=", + "checksumSHA1": "xKA5NvBoR4p257SEXsEzbYKhYV0=", "path": "github.com/nanobox-io/nanobox-router", - "revision": "3802731d4f79d6df47e740947050729a5b926f45", - "revisionTime": "2017-05-17T20:41:27Z" + "revision": "059779d975f5d9ed9913423d5e074e54edf4b501", + "revisionTime": "2017-07-03T23:17:23Z" }, { "checksumSHA1": "65+hx0QlLzpWe5pnjAzteKBnC10=",