Caddy: improve error handling and start working on language redirect for homepage

This commit is contained in:
Marko Korhonen 2024-05-12 16:31:44 +03:00
parent 9760f03c00
commit ff510d3b02
Signed by: FunctionalHacker
GPG key ID: A7F78BCB859CD890

View file

@ -22,6 +22,16 @@ korhonen.cc, *.korhonen.cc {
@homepage host korhonen.cc @homepage host korhonen.cc
handle @homepage { handle @homepage {
# Redirect finnish WIP
# @redirFinnish {
# header Accept-Language *fi-FI*
# not path *.js *.css *.png *.jpg *.jpeg *.svg
# not path /en* /fi*
# }
# redir @redirFinnish /fi{uri}
#
# uri strip_prefix /en
header @static Cache-Control max-age=5184000 header @static Cache-Control max-age=5184000
root * /var/www/korhonen.cc root * /var/www/korhonen.cc
file_server file_server
@ -52,7 +62,7 @@ korhonen.cc, *.korhonen.cc {
@forgejo host git.korhonen.cc @forgejo host git.korhonen.cc
handle @forgejo { handle @forgejo {
rewrite /user/login /user/oauth2/authentik rewrite /user/login /user/oauth2/authentik
reverse_proxy forgejo:3000 reverse_proxy forgejo:3000
} }
@ -89,8 +99,8 @@ korhonen.cc, *.korhonen.cc {
@nextcloud host cloud.korhonen.cc @nextcloud host cloud.korhonen.cc
handle @nextcloud { handle @nextcloud {
# Redirect login page to Authentik # Redirect login page to Authentik
redir /login /apps/sociallogin/custom_oidc/korhonen-sso 301 redir /login /apps/sociallogin/custom_oidc/korhonen-sso 301
# .htaccess / data / config / ... shouldn't be accessible from outside # .htaccess / data / config / ... shouldn't be accessible from outside
@forbidden { @forbidden {
@ -142,15 +152,22 @@ korhonen.cc, *.korhonen.cc {
reverse_proxy drop:3000 reverse_proxy drop:3000
} }
# Redirect to new fediverse host handle {
@misskey host social.korhonen.cc respond "404 Not Found" 404
handle @misskey {
redir https://korhonen.social
} }
# Fallback for unhandled domains handle_errors {
handle { @homepage_404 {
redir https://korhonen.cc/404.html 301 expression {http.error.status_code} == 404
host korhonen.cc
}
handle @homepage_404 {
root * /var/www/korhonen.cc
rewrite * /404.html
file_server
}
respond "{err.status_code} {err.status_text}"
} }
} }
@ -175,4 +192,12 @@ korhonen.social, *.korhonen.social {
handle @firefish { handle @firefish {
reverse_proxy firefish:3000 reverse_proxy firefish:3000
} }
handle {
respond "404 Not Found" 404
}
handle_errors {
respond "{err.status_code} {err.status_text}"
}
} }