# Written by the inbuxa installer {{.Version}} for {{.Domain}}. # # For the web server already on this machine: Caddy. Import it from your # Caddyfile (`import {{.Dir}}/proxy/Caddyfile.fragment`) and reload. It has no # global options block, so it can sit beside your own sites. The installer # loads nothing and restarts nothing. # # Everything is passed to loopback: 8081 the mail server, 8082 the console, # 8080 the webmail. Caddy gets certificates for the console and the webmail # itself. {{- if .ServesServer}} # The mail server's names. Caddy uses TLS-ALPN-01 for them and leaves HTTP-01 # on port 80 to the mail server, which needs a certificate of its own for # IMAP and SMTP: so neither answers the other's challenge. # # Caddy can't pass TLS through by name without the layer4 plugin, so it # terminates these names itself, with certificates of its own. Two things # follow. A domain added to the server later is not here: add its names to # both blocks below. And with TLSA records published, the server's _443._tcp # ones describe its own certificate, not Caddy's, so they don't match on 443 # (the mail ports are unaffected). The nginx configuration beside this passes # the server's names through to the server instead. {{join .ServerNames ", "}} { tls { issuer acme { email {{.Email}} disable_http_challenge } } reverse_proxy 127.0.0.1:8081 { flush_interval -1 } } {{range $i, $n := .ServerNames}}{{if $i}}, {{end}}http://{{$n}}{{end}} { handle /.well-known/acme-challenge/* { reverse_proxy 127.0.0.1:8081 } handle { redir https://{host}{uri} 308 } } {{- end}} {{- if .Console}} {{.ConsoleHost}} { encode zstd gzip reverse_proxy 127.0.0.1:8082 } {{- end}} {{- if .ConsoleFiles}} # The console, installed on this machine as files. {{.ConsoleHost}} { encode zstd gzip root * {{.ConsoleFiles}} try_files {path} /index.html header /assets/* Cache-Control "public, max-age=31536000, immutable" @page not path /assets/* header @page Cache-Control "no-cache" file_server } {{- end}} {{- if .ServesWebmail}} {{.WebmailHost}} { encode zstd gzip reverse_proxy 127.0.0.1:8080 { flush_interval -1 } } {{- end}}