Commit 264c555b authored by Lukáš Lalinský's avatar Lukáš Lalinský

Add /_health handler

parent 0176b673
Pipeline #20292 passed with stage
in 30 seconds
......@@ -109,12 +109,16 @@ userlist users_{{.Name}}
frontend fe_http
bind *:80
acl is_health path_beg /_health
use_backend be_utils if is_health
acl is_letsencrypt path_beg /.well-known/acme-challenge
redirect scheme https code 301 if !is_letsencrypt
use_backend be_letsencrypt if is_letsencrypt
frontend fe_https
bind *:443 ssl crt {{$.SSLDir}} alpn h2,http/1.1
acl is_health path_beg /_health
use_backend be_utils if is_health
acl is_letsencrypt path_beg /.well-known/acme-challenge
use_backend be_letsencrypt if is_letsencrypt
{{range $site := .Sites}}
......@@ -140,6 +144,11 @@ frontend fe_https
{{end}}
{{- end}}
backend be_utils
balance roundrobin
server srv 127.0.0.1:{{.UtilsServerPort}}
backend be_letsencrypt
balance roundrobin
option httpchk GET /_health
......@@ -211,6 +220,7 @@ type ProxyServer struct {
EnableHTTPLog bool
shutdown bool
shutdownDelay time.Duration
UtilsServerPort int
}
// NewProxyServer creates a new ProxyServer instance.
......@@ -229,6 +239,7 @@ func NewProxyServer() *ProxyServer {
SitesDir: defaultSitesDir,
LetsEncrypt: le,
SSLDir: haproxySSLDir,
UtilsServerPort: defaultProxyUtilsServerPort,
}
}
......@@ -519,7 +530,7 @@ func (p *ProxyServer) handleHealth(writer http.ResponseWriter, request *http.Req
func (p *ProxyServer) runUtilsServer() error {
mux := http.NewServeMux()
mux.HandleFunc("/_health", p.handleHealth)
server := &http.Server{Addr: fmt.Sprintf(":%d", defaultProxyUtilsServerPort), Handler: mux}
server := &http.Server{Addr: fmt.Sprintf(":%d", p.UtilsServerPort), Handler: mux}
return server.ListenAndServe()
}
......
......@@ -133,12 +133,16 @@ userlist users_example2
frontend fe_http
bind *:80
acl is_health path_beg /_health
use_backend be_utils if is_health
acl is_letsencrypt path_beg /.well-known/acme-challenge
redirect scheme https code 301 if !is_letsencrypt
use_backend be_letsencrypt if is_letsencrypt
frontend fe_https
bind *:443 ssl crt /etc/haproxy/ssl/ alpn h2,http/1.1
acl is_health path_beg /_health
use_backend be_utils if is_health
acl is_letsencrypt path_beg /.well-known/acme-challenge
use_backend be_letsencrypt if is_letsencrypt
......@@ -158,6 +162,11 @@ frontend fe_https
use_backend be_example2_default if domain_example2 route_example2_0 auth_example2
backend be_utils
balance roundrobin
server srv 127.0.0.1:12813
backend be_letsencrypt
balance roundrobin
option httpchk GET /_health
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment