public-access-proxy: fix wildcard matches

This commit is contained in:
Astro 2021-09-01 21:42:03 +02:00
parent b1ae3b6013
commit dbccd2df17
1 changed files with 6 additions and 4 deletions

View File

@ -3,6 +3,8 @@
with lib;
let cfg = config.my.services.proxy;
withoutWildcards = builtins.replaceStrings ["*"] ["all"];
in {
options.my.services.proxy = {
@ -98,8 +100,8 @@ in {
optionalString
(proxyHost.hostNames != [ ] && proxyHost.proxyTo.host != null)
(concatMapStringsSep "\n" (hostname: ''
use-server ${hostname}-http if { req.hdr(host) -i ${hostname} }
server ${hostname}-http ${proxyHost.proxyTo.host}:${
use-server ${withoutWildcards hostname}-http if { req.hdr(host) -i ${hostname} }
server ${withoutWildcards hostname}-http ${proxyHost.proxyTo.host}:${
toString proxyHost.proxyTo.httpPort
} weight 0
'') (proxyHost.hostNames))) (cfg.proxyHosts)
@ -117,8 +119,8 @@ in {
optionalString
(proxyHost.hostNames != [ ] && proxyHost.proxyTo.host != null)
(concatMapStringsSep "\n" (hostname: ''
use-server ${hostname}-https if { req.ssl_sni -i ${hostname} }
server ${hostname}-https ${proxyHost.proxyTo.host}:${
use-server ${withoutWildcards hostname}-https if { req.ssl_sni -i ${hostname} }
server ${withoutWildcards hostname}-https ${proxyHost.proxyTo.host}:${
toString proxyHost.proxyTo.httpsPort
} weight 0
'') (proxyHost.hostNames))) (cfg.proxyHosts)