Skip to content

Commit

Permalink
adding SELF_MANAGED_CERTS option
Browse files Browse the repository at this point in the history
  • Loading branch information
traceypooh committed Nov 4, 2024
1 parent 30b2841 commit 5941484
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ ENV REVERSE_PROXY ""
ENV ON_DEMAND_TLS_ASK ""
ENV HTTP_DISABLED ""
ENV ALLOWED_REMOTE_IPS ""
ENV SELF_MANAGED_CERTS ""
ENV HOST_UNAME Linux

# replaced at runtime:
Expand Down
27 changes: 20 additions & 7 deletions etc/Caddyfile.ctmpl
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,6 @@ http:// {
}


#example.com {
# Specify the paths to your SSL certificate and private key
# xxx hostname => $dom
# tls /pv/CERTS/$dom.crt /pv/CERTS/$dom.key
#}


# start off with nice, easy way(s) to get to nomad
{{- $NAMES_INTO_NOMAD := env "FQDN" }}
{{- $extra := env "NOMAD_ADDR_EXTRA" }}
Expand All @@ -43,6 +36,11 @@ https://{{- . }} {
tls {
on_demand
}
{{ end }}
{{ if ne (env "SELF_MANAGED_CERTS") "" }}
{{ $dom := . }}
{{ $dom := $dom | regexReplaceAll "^https*://" "" | regexReplaceAll ":[0-9][0-9]+.*$" "" | regexReplaceAll "^[^.]*[.]([^.]*[.][^.]*)$" "$1" | regexReplaceAll "^[^.]*[.]([^.]*[.][^.]*[.][^.]*)$" "$1" }}
tls /pv/CERTS/{{ $dom }}.crt /pv/CERTS/{{ $dom }}.key
{{ end }}
log
}
Expand All @@ -60,6 +58,11 @@ https://{{- . }} {
tls {
on_demand
}
{{ end }}
{{ if ne (env "SELF_MANAGED_CERTS") "" }}
{{ $dom := $hosty }}
{{ $dom := $dom | regexReplaceAll "^https*://" "" | regexReplaceAll ":[0-9][0-9]+.*$" "" | regexReplaceAll "^[^.]*[.]([^.]*[.][^.]*)$" "$1" | regexReplaceAll "^[^.]*[.]([^.]*[.][^.]*[.][^.]*)$" "$1" }}
tls /pv/CERTS/{{ $dom }}.crt /pv/CERTS/{{ $dom }}.key
{{ end }}
log
}
Expand All @@ -74,6 +77,11 @@ https://{{ $hosty }} {
tls {
on_demand
}
{{ end }}
{{ if ne (env "SELF_MANAGED_CERTS") "" }}
{{ $dom := $hosty }}
{{ $dom := $dom | regexReplaceAll "^https*://" "" | regexReplaceAll ":[0-9][0-9]+.*$" "" | regexReplaceAll "^[^.]*[.]([^.]*[.][^.]*)$" "$1" | regexReplaceAll "^[^.]*[.]([^.]*[.][^.]*[.][^.]*)$" "$1" }}
tls /pv/CERTS/{{ $dom }}.crt /pv/CERTS/{{ $dom }}.key
{{ end }}
log
}
Expand Down Expand Up @@ -133,6 +141,11 @@ http://{{ $hosty }} {
tls {
on_demand
}
{{ end }}
{{ if ne (env "SELF_MANAGED_CERTS") "" }}
{{ $dom := $origin }}
{{ $dom := $dom | regexReplaceAll "^https*://" "" | regexReplaceAll ":[0-9][0-9]+.*$" "" | regexReplaceAll "^[^.]*[.]([^.]*[.][^.]*)$" "$1" | regexReplaceAll "^[^.]*[.]([^.]*[.][^.]*[.][^.]*)$" "$1" }}
tls /pv/CERTS/{{ $dom }}.crt /pv/CERTS/{{ $dom }}.key
{{ end }}
log
}
Expand Down

0 comments on commit 5941484

Please sign in to comment.