2020-01-10 04:49:30 +00:00
global
2020-09-10 00:52:57 +00:00
lua-prepend-path /usr/local/etc/haproxy/?/http.lua
2020-01-10 04:49:30 +00:00
lua-load /usr/local/etc/haproxy/auth-request.lua
log stdout format raw local0 debug
2023-02-17 04:05:48 +00:00
maxconn 2000
2020-01-10 04:49:30 +00:00
defaults
2021-11-05 13:14:42 +00:00
default-server init-addr none
2020-01-10 04:49:30 +00:00
mode http
2023-02-17 04:05:48 +00:00
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms
2020-01-10 04:49:30 +00:00
log global
option forwardfor
2023-01-25 09:36:40 +00:00
option httplog
option httpchk
http-check expect rstatus ^2
2020-01-10 04:49:30 +00:00
2021-11-05 13:14:42 +00:00
resolvers docker
nameserver ip 127.0.0.11:53
2020-01-10 04:49:30 +00:00
frontend fe_api
2023-02-17 04:05:48 +00:00
bind *:8081 ssl crt /pki/private.chain.pem
2020-01-10 04:49:30 +00:00
stats enable
stats uri /api
stats refresh 10s
stats admin if LOCALHOST
frontend fe_http
2023-02-17 04:05:48 +00:00
bind *:8080 ssl crt /pki/private.chain.pem
2020-01-10 04:49:30 +00:00
acl api-path path_beg -i /api
2023-01-25 04:11:05 +00:00
acl devworkflow-path path -i -m end /devworkflow
2020-09-23 07:29:46 +00:00
acl headers-path path -i -m end /headers
2023-01-25 09:36:40 +00:00
acl jwks-path path -i -m end /jwks.json
acl locales-path path_beg -i /locales
acl wellknown-path path_beg -i /.well-known
2020-09-23 07:29:46 +00:00
acl host-authelia-portal hdr(host) -i login.example.com:8080
2020-11-24 01:35:38 +00:00
acl protected-frontends hdr(host) -m reg -i ^(?i)(admin|home|public|secure|singlefactor)\.example\.com
2020-01-10 04:49:30 +00: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 }
http-request set-header X-Real-IP %[src]
2023-04-08 04:48:55 +00:00
http-request set-header X-Forwarded-Method %[method]
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-01-10 04:49:30 +00:00
2020-04-13 23:57:28 +00: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).
2023-04-08 04:48:55 +00:00
http-request lua.auth-intercept be_auth_request /api/authz/forward-auth HEAD * authorization,proxy-authorization,remote_user,remote-user,remote-groups,remote-name,remote-email - if protected-frontends
http-request redirect location %[var(txn.auth_response_location)] if protected-frontends !{ var(txn.auth_response_successful) -m bool }
2020-05-06 01:50:37 +00:00
2023-01-25 09:36:40 +00:00
use_backend be_authelia if host-authelia-portal api-path || devworkflow-path || jwks-path || locales-path || wellknown-path
2020-01-10 04:49:30 +00:00
use_backend fe_authelia if host-authelia-portal !api-path
2020-09-23 07:29:46 +00:00
use_backend be_httpbin if protected-frontends headers-path
2020-01-10 04:49:30 +00:00
use_backend be_mail if { hdr(host) -i mail.example.com:8080 }
2020-09-23 07:29:46 +00:00
use_backend be_protected if protected-frontends
2020-04-13 23:57:28 +00:00
backend be_auth_request
2020-09-22 23:06:26 +00:00
server proxy 127.0.0.1:8085
2020-04-13 23:57:28 +00:00
listen be_auth_request_proxy
2020-09-22 23:06:26 +00:00
bind 127.0.0.1:8085
2021-11-05 13:14:42 +00:00
server authelia-backend authelia-backend:9091 resolvers docker ssl verify none
2020-01-10 04:49:30 +00:00
2020-09-23 07:29:46 +00:00
backend be_authelia
2021-11-05 13:14:42 +00:00
server authelia-backend authelia-backend:9091 resolvers docker ssl verify none
2020-09-23 07:29:46 +00:00
2020-01-10 04:49:30 +00:00
backend fe_authelia
2023-01-25 04:11:05 +00:00
option httpchk
http-check expect rstatus ^2
2022-05-02 04:50:37 +00:00
server authelia-frontend authelia-frontend:3000 check resolvers docker
server authelia-backend authelia-backend:9091 check backup resolvers docker ssl verify none
2020-01-10 04:49:30 +00:00
2020-05-06 01:50:37 +00:00
backend be_httpbin
2023-02-02 07:13:18 +00:00
## Pass the Set-Cookie response headers to the user.
acl set_cookie_exist var(req.auth_response_header.set_cookie) -m found
http-response set-header Set-Cookie %[var(req.auth_response_header.set_cookie)] if set_cookie_exist
2021-11-05 13:14:42 +00:00
server httpbin-backend httpbin:8000 resolvers docker
2020-09-23 07:29:46 +00:00
backend be_mail
2021-11-05 13:14:42 +00:00
server smtp-backend smtp:1080 resolvers docker
2020-09-23 07:29:46 +00:00
backend be_protected
2023-04-08 04:48:55 +00:00
## Pass the Set-Cookie response headers to the user.
acl set_cookie_exist var(req.auth_response_header.set_cookie) -m found
http-response set-header Set-Cookie %[var(req.auth_response_header.set_cookie)] if set_cookie_exist
2021-11-05 13:14:42 +00:00
server nginx-backend nginx-backend:80 resolvers docker