diff --git a/haproxy/haproxy.cfg b/haproxy/haproxy.cfg index a35951c..e9896ff 100644 --- a/haproxy/haproxy.cfg +++ b/haproxy/haproxy.cfg @@ -76,14 +76,14 @@ frontend http-in acl ddos_mode_enabled base,map(/etc/haproxy/map/ddos.map) -m bool # serve challenge page scripts directly from haproxy - http-request return file /etc/haproxy/js/auto.min.js status 200 content-type "application/javascript; charset=utf-8" hdr "cache-control" "public, max-age=86400" if { path /.basedflare/js/auto.min.js } - http-request return file /etc/haproxy/js/argon2.min.js status 200 content-type "application/javascript; charset=utf-8" hdr "cache-control" "public, max-age=86400" if { path /.basedflare/js/argon2.min.js } - http-request return file /etc/haproxy/js/challenge.js status 200 content-type "application/javascript; charset=utf-8" hdr "cache-control" "public, max-age=86400" if { path /.basedflare/js/challenge.min.js } - http-request return file /etc/haproxy/js/worker.min.js status 200 content-type "application/javascript; charset=utf-8" hdr "cache-control" "public, max-age=86400" if { path /.basedflare/js/worker.min.js } + http-request return file /etc/haproxy/js/auto.min.js status 200 content-type "application/javascript; charset=utf-8" hdr "Cache-Control" "public, max-age=86400" if { path /.basedflare/js/auto.min.js } + http-request return file /etc/haproxy/js/argon2.min.js status 200 content-type "application/javascript; charset=utf-8" hdr "Cache-Control" "public, max-age=86400" if { path /.basedflare/js/argon2.min.js } + http-request return file /etc/haproxy/js/challenge.js status 200 content-type "application/javascript; charset=utf-8" hdr "Cache-Control" "public, max-age=86400" if { path /.basedflare/js/challenge.min.js } + http-request return file /etc/haproxy/js/worker.min.js status 200 content-type "application/javascript; charset=utf-8" hdr "Cache-Control" "public, max-age=86400" if { path /.basedflare/js/worker.min.js } # acl for domains in maintenance mode to return maintenance page (after challenge page htp-request return rules, for the footerlogo) acl maintenance_mode hdr(host),lower,map_str(/etc/haproxy/map/maintenance.map) -m found - http-request return lf-file /etc/haproxy/template/maintenance.html status 200 content-type "text/html; charset=utf-8" hdr "cache-control" "private, max-age=30" if maintenance_mode + use_backend maintenance if maintenance_mode # rewrite specific domain+path to domain or domain+path http-request redirect location https://%[base,map(/etc/haproxy/map/rewrite.map)] code 302 if { base,map(/etc/haproxy/map/rewrite.map) -i -m found } @@ -114,18 +114,39 @@ frontend http-in # simple example cache for files http-request set-var(txn.path) path acl can_cache var(txn.path) -i -m end .png .jpg .jpeg .jpe .ico .webmanifest .xml .apng .bmp .webp .pjpeg .jfif .gif .mp4 .webm .mov .mkv .svg .m4a .aac .flac .mp3 .ogg .wav .opus .txt .pdf .sid - http-request cache-use basic_cache if can_cache - http-response cache-store basic_cache if can_cache + # optional alt-svc header (done after cache so not set in cached responses http-response set-header Alt-Svc %[var(txn.xcn),map(/etc/haproxy/map/alt-svc.map)] + acl c0 res.hdr(Cache-Control,0) -m sub max-age=0 + acl c0 res.hdr(Cache-Control,1) -m sub max-age=0 + acl c0 res.hdr(Cache-Control,2) -m sub max-age=0 + acl cf0 res.fhdr(Cache-Control,0) -m sub max-age=0 + acl cf0 res.fhdr(Cache-Control,1) -m sub max-age=0 + acl cf0 res.fhdr(Cache-Control,2) -m sub max-age=0 + http-response set-header X-c0 true if c0 + http-response set-header X-cf0 true if cf0 + http-response set-header X-res-hdr0-Cache-Control %[res.hdr(Cache-Control,0)] + http-response set-header X-res-hdr1-Cache-Control %[res.hdr(Cache-Control,1)] + http-response set-header X-res-hdr2-Cache-Control %[res.hdr(Cache-Control,2)] + http-response set-header X-res-fhdr0-Cache-Control %[res.fhdr(Cache-Control,0)] + http-response set-header X-res-fhdr1-Cache-Control %[res.fhdr(Cache-Control,1)] + http-response set-header X-res-fhdr2-Cache-Control %[res.fhdr(Cache-Control,2)] + + http-request cache-use basic_cache + http-response cache-store basic_cache default_backend servers cache basic_cache - total-max-size 2500 + total-max-size 250 max-object-size 31457280 max-age 86400 + process-vary on + +backend maintenance + http-request lua.set-lang-json + http-request return lf-file /etc/haproxy/template/maintenance.html status 200 content-type "text/html; charset=utf-8" hdr "Cache-Control" "private, max-age=30" backend servers balance leastconn diff --git a/haproxy/map/hosts.map b/haproxy/map/hosts.map index fc61161..3648f14 100644 --- a/haproxy/map/hosts.map +++ b/haproxy/map/hosts.map @@ -1,2 +1,2 @@ 127.0.0.1 127.0.0.1:81 -localhost 127.0.0.1:81 +localhost 127.0.0.1:8200 diff --git a/haproxy/map/maintenance.map b/haproxy/map/maintenance.map index e69de29..3d56e87 100644 --- a/haproxy/map/maintenance.map +++ b/haproxy/map/maintenance.map @@ -0,0 +1 @@ +localhost admin diff --git a/haproxy/template/maintenance.html b/haproxy/template/maintenance.html index cf7565d..f4d23e2 100644 --- a/haproxy/template/maintenance.html +++ b/haproxy/template/maintenance.html @@ -2,7 +2,7 @@
-