Add unavailable page when PHP-FPM is down: Caddy handle_errors on 502/503

- Create unavailable.html static page with neo-brutalist design and retry button
- Add handle_errors in Caddy for 502/503: serve unavailable.html
- Add dial/read/write timeouts to php_fastcgi (5s/30s/30s)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Serreau Jovann
2026-03-20 20:14:41 +01:00
parent 00a2ebe79d
commit bbe727b1d4
2 changed files with 39 additions and 1 deletions

View File

@@ -3,7 +3,7 @@ ticket.e-cosplay.fr {
dns cloudflare {{ cloudflare_api_token }} dns cloudflare {{ cloudflare_api_token }}
} }
@static path /logo.png /favicon.ico /favicon.png /marker.png /screen.png /manifest.json /site.webmanifest /sw.js /workbox/* /idb/* /build/* /uploads/* /pwa/* @static path /logo.png /favicon.ico /favicon.png /marker.png /screen.png /manifest.json /site.webmanifest /sw.js /unavailable.html /workbox/* /idb/* /build/* /uploads/* /pwa/*
handle @static { handle @static {
root * /var/www/e-ticket/public root * /var/www/e-ticket/public
file_server file_server
@@ -38,11 +38,23 @@ ticket.e-cosplay.fr {
root /app/public root /app/public
lb_policy round_robin lb_policy round_robin
trusted_proxies private_ranges trusted_proxies private_ranges
dial_timeout 5s
read_timeout 30s
write_timeout 30s
} }
file_server file_server
try_files {path} /index.php?{query} try_files {path} /index.php?{query}
} }
handle_errors {
@unavailable expression `{err.status_code} in [502, 503]`
handle @unavailable {
root * /var/www/e-ticket/public
rewrite * /unavailable.html
file_server
}
}
encode gzip encode gzip
header { header {

26
public/unavailable.html Normal file
View File

@@ -0,0 +1,26 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Site indisponible - E-Ticket</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: #fbfbfb; font-family: system-ui, sans-serif; color: #111827; padding: 1rem; }
.card { border: 4px solid #111827; box-shadow: 6px 6px 0 #111827; background: white; padding: 3rem; max-width: 500px; width: 100%; text-align: center; }
h1 { font-size: 2rem; font-weight: 900; text-transform: uppercase; letter-spacing: -0.05em; font-style: italic; margin-bottom: 1rem; }
p { font-weight: 700; color: #6b7280; font-style: italic; margin-bottom: 1.5rem; }
.icon { font-size: 3rem; margin-bottom: 1rem; }
.btn { display: inline-block; padding: 0.75rem 2rem; border: 3px solid #111827; box-shadow: 4px 4px 0 #111827; background: #fabf04; font-weight: 900; text-transform: uppercase; font-size: 0.875rem; letter-spacing: 0.1em; text-decoration: none; color: #111827; cursor: pointer; }
.btn:hover { background: #4f46e5; color: white; }
</style>
</head>
<body>
<div class="card">
<div class="icon">&#9888;</div>
<h1>Site temporairement indisponible</h1>
<p>Le serveur ne repond pas pour le moment. Veuillez reessayer dans quelques instants.</p>
<a href="/" class="btn" onclick="location.reload(); return false;">Reessayer</a>
</div>
</body>
</html>