mirror of https://github.com/k3s-io/k3s
70 lines
1.8 KiB
INI
70 lines
1.8 KiB
INI
# This file uses golang text templates (http://golang.org/pkg/text/template/) to
|
|
# dynamically configure the haproxy loadbalancer.
|
|
global
|
|
daemon
|
|
stats socket /tmp/haproxy
|
|
|
|
defaults
|
|
log global
|
|
option dontlognull
|
|
timeout connect 5000
|
|
timeout client 50000
|
|
timeout server 50000
|
|
|
|
# haproxy stats, required hostport and firewall rules for :1936
|
|
listen stats :1936
|
|
mode http
|
|
stats enable
|
|
stats hide-version
|
|
stats realm Haproxy\ Statistics
|
|
stats uri /
|
|
|
|
frontend httpfrontend
|
|
# Frontend bound on all network interfaces on port 80
|
|
bind *:80
|
|
mode http
|
|
|
|
# inherit default mode, needs changing for tcp
|
|
# forward everything meant for /foo to the foo backend
|
|
# default_backend foo
|
|
{{range $i, $svc := .httpServices}}
|
|
acl url_{{$svc.Name}} path_beg /{{$svc.Name}}
|
|
use_backend {{$svc.Name}} if url_{{$svc.Name}}
|
|
{{end}}
|
|
|
|
{{range $i, $svc := .httpServices}}
|
|
{{ $svcName := $svc.Name }}
|
|
backend {{$svc.Name}}
|
|
mode http
|
|
option httplog
|
|
errorfile 400 /etc/haproxy/errors/400.http
|
|
errorfile 403 /etc/haproxy/errors/403.http
|
|
errorfile 408 /etc/haproxy/errors/408.http
|
|
errorfile 500 /etc/haproxy/errors/500.http
|
|
errorfile 502 /etc/haproxy/errors/502.http
|
|
errorfile 503 /etc/haproxy/errors/503.http
|
|
errorfile 504 /etc/haproxy/errors/504.http
|
|
|
|
balance roundrobin
|
|
# TODO: Make the path used to access a service customizable.
|
|
reqrep ^([^\ :]*)\ /{{$svc.Name}}[/]?(.*) \1\ /\2
|
|
{{range $j, $ep := $svc.Ep}}server {{$svcName}}_{{$j}} {{$ep}} check
|
|
{{end}}
|
|
{{end}}
|
|
|
|
|
|
|
|
{{range $i, $svc := .tcpServices}}
|
|
{{ $svcName := $svc.Name }}
|
|
frontend {{$svc.Name}}
|
|
bind *:{{$svc.FrontendPort}}
|
|
mode tcp
|
|
default_backend {{$svc.Name}}
|
|
|
|
backend {{$svc.Name}}
|
|
balance roundrobin
|
|
mode tcp
|
|
{{range $j, $ep := $svc.Ep}}server {{$svcName}}_{{$j}} {{$ep}} check
|
|
{{end}}
|
|
{{end}}
|