2020-01-10 11:49:30 +07:00
|
|
|
global
|
2020-09-10 07:52:57 +07:00
|
|
|
lua-prepend-path /usr/local/etc/haproxy/?/http.lua
|
2020-01-10 11:49:30 +07:00
|
|
|
lua-load /usr/local/etc/haproxy/auth-request.lua
|
|
|
|
log stdout format raw local0 debug
|
|
|
|
|
|
|
|
defaults
|
|
|
|
mode http
|
|
|
|
log global
|
|
|
|
option httplog
|
|
|
|
option forwardfor
|
|
|
|
|
|
|
|
frontend fe_api
|
|
|
|
bind *:8081 ssl crt /usr/local/etc/haproxy/haproxy.pem
|
|
|
|
|
|
|
|
stats enable
|
|
|
|
stats uri /api
|
|
|
|
stats refresh 10s
|
|
|
|
stats admin if LOCALHOST
|
|
|
|
|
|
|
|
frontend fe_http
|
|
|
|
bind *:8080 ssl crt /usr/local/etc/haproxy/haproxy.pem
|
|
|
|
|
|
|
|
acl api-path path_beg -i /api
|
2020-09-23 14:29:46 +07:00
|
|
|
acl headers-path path -i -m end /headers
|
|
|
|
acl host-authelia-portal hdr(host) -i login.example.com:8080
|
2020-11-24 08:35:38 +07:00
|
|
|
acl protected-frontends hdr(host) -m reg -i ^(?i)(admin|home|public|secure|singlefactor)\.example\.com
|
2020-01-10 11:49:30 +07:00
|
|
|
|
|
|
|
http-request set-var(req.scheme) str(https) if { ssl_fc }
|
|
|
|
http-request set-var(req.scheme) str(http) if !{ ssl_fc }
|
|
|
|
http-request set-var(req.questionmark) str(?) if { query -m found }
|
2021-03-05 11:18:31 +07:00
|
|
|
http-request set-var(req.method) str(CONNECT) if { method CONNECT }
|
|
|
|
http-request set-var(req.method) str(GET) if { method GET }
|
|
|
|
http-request set-var(req.method) str(HEAD) if { method HEAD }
|
|
|
|
http-request set-var(req.method) str(OPTIONS) if { method OPTIONS }
|
|
|
|
http-request set-var(req.method) str(POST) if { method POST }
|
|
|
|
http-request set-var(req.method) str(TRACE) if { method TRACE }
|
|
|
|
http-request set-var(req.method) str(PUT) if { method PUT }
|
|
|
|
http-request set-var(req.method) str(PATCH) if { method PATCH }
|
|
|
|
http-request set-var(req.method) str(DELETE) if { method DELETE }
|
|
|
|
http-request set-header X-Forwarded-Method %[var(req.method)]
|
2020-01-10 11:49:30 +07:00
|
|
|
|
|
|
|
http-request set-header X-Real-IP %[src]
|
|
|
|
http-request set-header X-Forwarded-Proto %[var(req.scheme)]
|
|
|
|
http-request set-header X-Forwarded-Host %[req.hdr(Host)]
|
|
|
|
http-request set-header X-Forwarded-Uri %[path]%[var(req.questionmark)]%[query]
|
|
|
|
|
2020-04-14 06:57:28 +07:00
|
|
|
# be_auth_request is used to make HAProxy do the TLS termination since the Lua script
|
|
|
|
# does not know how to handle it (see https://github.com/TimWolla/haproxy-auth-request/issues/12).
|
|
|
|
http-request lua.auth-request be_auth_request /api/verify if protected-frontends
|
2020-01-10 11:49:30 +07:00
|
|
|
|
2020-09-23 06:06:26 +07:00
|
|
|
http-request redirect location https://login.example.com:8080/?rd=%[var(req.scheme)]://%[base]%[var(req.questionmark)]%[query] if protected-frontends !{ var(txn.auth_response_successful) -m bool }
|
2020-05-06 08:50:37 +07:00
|
|
|
|
2020-01-10 11:49:30 +07:00
|
|
|
use_backend be_authelia if host-authelia-portal api-path
|
|
|
|
use_backend fe_authelia if host-authelia-portal !api-path
|
2020-09-23 14:29:46 +07:00
|
|
|
use_backend be_httpbin if protected-frontends headers-path
|
2020-01-10 11:49:30 +07:00
|
|
|
use_backend be_mail if { hdr(host) -i mail.example.com:8080 }
|
2020-09-23 14:29:46 +07:00
|
|
|
use_backend be_protected if protected-frontends
|
2020-04-14 06:57:28 +07:00
|
|
|
|
|
|
|
backend be_auth_request
|
2020-09-23 06:06:26 +07:00
|
|
|
mode http
|
|
|
|
server proxy 127.0.0.1:8085
|
2020-04-14 06:57:28 +07:00
|
|
|
|
|
|
|
listen be_auth_request_proxy
|
2020-09-23 06:06:26 +07:00
|
|
|
mode http
|
|
|
|
bind 127.0.0.1:8085
|
|
|
|
server authelia-backend authelia-backend:9091 ssl verify none
|
2020-01-10 11:49:30 +07:00
|
|
|
|
2020-09-23 14:29:46 +07:00
|
|
|
backend be_authelia
|
|
|
|
server authelia-backend authelia-backend:9091 ssl verify none
|
|
|
|
|
2020-01-10 11:49:30 +07:00
|
|
|
backend fe_authelia
|
|
|
|
server authelia-frontend authelia-frontend:3000
|
|
|
|
|
2020-05-06 08:50:37 +07:00
|
|
|
backend be_httpbin
|
2020-09-10 07:52:57 +07:00
|
|
|
acl remote_user_exist var(req.auth_response_header.remote_user) -m found
|
|
|
|
acl remote_groups_exist var(req.auth_response_header.remote_groups) -m found
|
2020-10-26 18:38:08 +07:00
|
|
|
acl remote_name_exist var(req.auth_response_header.remote_name) -m found
|
|
|
|
acl remote_email_exist var(req.auth_response_header.remote_email) -m found
|
2020-09-10 07:52:57 +07:00
|
|
|
http-request set-header Remote-User %[var(req.auth_response_header.remote_user)] if remote_user_exist
|
|
|
|
http-request set-header Remote-Groups %[var(req.auth_response_header.remote_groups)] if remote_groups_exist
|
2020-10-26 18:38:08 +07:00
|
|
|
http-request set-header Remote-Name %[var(req.auth_response_header.remote_name)] if remote_name_exist
|
|
|
|
http-request set-header Remote-Email %[var(req.auth_response_header.remote_email)] if remote_email_exist
|
2020-05-06 08:50:37 +07:00
|
|
|
|
2020-09-23 14:29:46 +07:00
|
|
|
server httpbin-backend httpbin:8000
|
|
|
|
|
|
|
|
backend be_mail
|
|
|
|
server smtp-backend smtp:1080
|
|
|
|
|
|
|
|
backend be_protected
|
2020-11-09 09:35:18 +07:00
|
|
|
server nginx-backend nginx-backend:80
|