CaddyFile ReverseProxy + PGADMIN
:80 {
# Active la journalisation pour le débogage
log
# 1. GESTION DES ERREURS (Erreurs 5xx, si un service est HS)
handle_errors {
rewrite * /erreur.html
file_server {
root /etc/caddy
}
}
# 2. REVERSE PROXY POUR /pgadmin4
handle /pgadmin* {
redir /pgadmin /pgadmin/ permanent
reverse_proxy pgadmin:5050 {
# pgadmin required this
header_up X-Scheme {scheme}
header_up X-Script-Name "/pgadmin"
header_up X-Real-IP {remote}
header_up X-Forwarded-Proto {scheme}
}
}
# 3. REVERSE PROXY PAR DÉFAUT
handle {
reverse_proxy puzzlesapp:5000
}
}
erreur.html
<!DOCTYPE html>
<html>
<head>
<title>Service Indisponible</title>
<style>
body { font-family: Arial, sans-serif; text-align: center; padding-top: 50px; }
h1 { color: #cc0000; }
</style>
</head>
<body>
<h1>🛑 Erreur de Connexion</h1>
<p>Nous sommes désolés, le service principal est actuellement hors ligne.</p>
<p>Veuillez réessayer plus tard.</p>
</body>
</html>
DockerCompose
caddy:
image: caddy:latest
container_name: caddy
restart: unless-stopped
ports:
# Mappe le port 80 du conteneur au port 80 de l'hôte
- 80:80
volumes:
# Mappe le Caddyfile local dans le conteneur
- /opt/puzzles/caddyfile:/etc/caddy/Caddyfile
- /opt/puzzles/erreur.html:/etc/caddy/erreur.html