use env vars for subdomain and domain in caddy

This commit is contained in:
2024-12-07 11:38:09 +01:00
parent 2b61a00841
commit 52fc271b71
9 changed files with 16 additions and 15 deletions

View File

@@ -8,7 +8,7 @@ import conf/*.caddy
} }
(unprotected) { (unprotected) {
{args[0]}.rik.veenboer.xyz { {args[0]}.{$SUBDOMAIN}.{$DOMAIN} {
log { log {
output file /var/log/{args[0]}.log output file /var/log/{args[0]}.log
} }
@@ -17,7 +17,7 @@ import conf/*.caddy
} }
(protected) { (protected) {
{args[0]}.rik.veenboer.xyz { {args[0]}.{$SUBDOMAIN}.{$DOMAIN} {
import authentik import authentik
reverse_proxy {args[1]} reverse_proxy {args[1]}
} }

View File

@@ -13,13 +13,12 @@
retry_attempts 3 retry_attempts 3
retry_interval 10 retry_interval 10
base_auth_url https://authentik.rik.veenboer.xyz base_auth_url https://authentik.{$SUBDOMAIN}.{$DOMAIN}
metadata_url https://authentik.rik.veenboer.xyz/application/o/caddy/.well-known/openid-configuration metadata_url https://authentik.{$SUBDOMAIN}.{$DOMAIN}/application/o/caddy/.well-known/openid-configuration
# metadata_url http://192.168.2.200:15000/caddy/.well-known/openid-configuration
} }
authentication portal myportal { authentication portal myportal {
enable identity provider generic enable identity provider generic
cookie domain veenboer.xyz cookie domain {$DOMAIN}
ui { ui {
links { links {
"My Identity" "/whoami" icon "las la-user" "My Identity" "/whoami" icon "las la-user"
@@ -40,7 +39,7 @@
} }
} }
authorization policy mypolicy { authorization policy mypolicy {
set auth url https://auth.rik.veenboer.xyz/oauth2/generic set auth url https://auth.{$SUBDOMAIN}.{$DOMAIN}/oauth2/generic
allow roles authp/admin authp/user allow roles authp/admin authp/user
validate bearer header validate bearer header
inject headers with claims inject headers with claims

View File

@@ -2,7 +2,7 @@
dynamic_dns { dynamic_dns {
provider route53 provider route53
domains { domains {
veenboer.xyz. rik {$DOMAIN}. {$SUBDOMAIN}
} }
versions ipv4 versions ipv4
} }

View File

@@ -1,4 +1,4 @@
authentik.veenboer.xyz { authentik.{$DOMAIN} {
log { log {
output file /var/log/authentik-root.log output file /var/log/authentik-root.log
} }

View File

@@ -1,4 +1,4 @@
geo.rik.veenboer.xyz { geo.{$SUBDOMAIN}.{$DOMAIN} {
log { log {
output file /var/log/geo.log output file /var/log/geo.log
} }

View File

@@ -1,4 +1,4 @@
ha.rik.veenboer.xyz { ha.{$SUBDOMAIN}.{$DOMAIN} {
log { log {
output file /var/log/ha.log output file /var/log/ha.log
} }

View File

@@ -1,5 +1,5 @@
rik.veenboer.xyz \ {$SUBDOMAIN}.{$DOMAIN} \
*.rik.veenboer.xyz \ *.{$SUBDOMAIN}.{$DOMAIN} \
{ {
handle_path /test/* { handle_path /test/* {
reverse_proxy host:12345 reverse_proxy host:12345

View File

@@ -1,4 +1,4 @@
test.rik.veenboer.xyz { test.{$SUBDOMAIN}.{$DOMAIN} {
log { log {
output file /var/log/test.log output file /var/log/test.log
} }
@@ -7,7 +7,7 @@ test.rik.veenboer.xyz {
reverse_proxy host:15000 reverse_proxy host:15000
} }
auth.rik.veenboer.xyz { auth.{$SUBDOMAIN}.{$DOMAIN} {
route { route {
authenticate with myportal authenticate with myportal
} }

View File

@@ -4,6 +4,8 @@ services:
context: /opt/caddy/ context: /opt/caddy/
container_name: caddy container_name: caddy
environment: environment:
- DOMAIN=veenboer.xyz
- SUBDOMAIN=rik
- AWS_REGION=eu-west-1 - AWS_REGION=eu-west-1
- AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID:?} - AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID:?}
- AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY:?} - AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY:?}