Switch from caddy to haproxy

This commit is contained in:
Hendrik Sokolowski 2022-05-01 00:05:53 +02:00
parent 67e90032c4
commit 9aafa7ff52

View file

@ -2,7 +2,9 @@
with lib; with lib;
let cfg = config.pub-solar.x-os; let
psCfg = config.pub-solar;
cfg = psCfg.x-os;
in in
{ {
options.pub-solar.x-os = { options.pub-solar.x-os = {
@ -34,21 +36,51 @@ in
# These entries get added to /etc/hosts # These entries get added to /etc/hosts
networking.hosts = { networking.hosts = {
"127.0.0.1" = [ "cups.local" ]; "127.0.0.1" = mkIf psCfg.printing.enable [ "cups.local" ];
}; };
# Caddy reverse proxy for local services like cups # ha reverse proxy for local services like cups
services.caddy = { services.haproxy.enable = true;
enable = true; services.haproxy.config = ''
config = '' global
{ maxconn 4096
auto_https off # user http
} # group http
cups.local:80 daemon
bind 127.0.0.1
request_header Host localhost:631 defaults
reverse_proxy unix//run/cups/cups.sock log global
mode http
option httplog
option dontlognull
retries 3
option redispatch
maxconn 2000
timeout connect 5000
timeout client 50000
timeout server 50000
log 127.0.0.1 local0
log 127.0.0.1 local7 debug
option httpchk
frontend http
bind 0.0.0.0:80
acl is_cups hdr_end(host) -i cups.local
acl is_local dst 127.0.0.1
use_backend cups if is_cups is_local
frontend vnc
bind 0.0.0.0:5901
mode tcp
use_backend vnc
backend cups
server cups unix@/run/cups/cups.sock
backend vnc
server vnc unix@/run/wayvnc.sock
''; '';
}; };
};
} }