Update deploy/varnish/default.vcl.template
This commit is contained in:
@@ -55,15 +55,6 @@ sub vcl_recv {
|
||||
}
|
||||
}
|
||||
|
||||
# ---- (Opcjonalnie) Normalizacja Accept dla obrazów generowanych wariantowo ----
|
||||
# if (req.url ~ "\.(png|jpe?g|gif|bmp)$") {
|
||||
# if (req.http.Accept ~ "image/webp") {
|
||||
# set req.http.X-Accept-Image = "modern"; # webp
|
||||
# } else {
|
||||
# set req.http.X-Accept-Image = "legacy"; # jpg/png
|
||||
# }
|
||||
# }
|
||||
|
||||
# ---- STATYCZNE – agresywny cache + ignorujemy sesję ----
|
||||
if (req.url ~ "^/static/" || req.url ~ "\.(css|js|png|jpe?g|webp|svg|ico|woff2?)$") {
|
||||
unset req.http.Cookie;
|
||||
@@ -90,12 +81,6 @@ sub vcl_recv {
|
||||
return (pass);
|
||||
}
|
||||
|
||||
# jeśli chcesz PASS przy cookie:
|
||||
# if (req.http.Cookie) {
|
||||
# set req.http.X-Pass-Reason = "cookie";
|
||||
# return (pass);
|
||||
# }
|
||||
|
||||
return (hash);
|
||||
}
|
||||
|
||||
@@ -254,7 +239,56 @@ sub vcl_deliver {
|
||||
unset resp.http.Server;
|
||||
}
|
||||
|
||||
# ===== SYNTH - ulepszony z HTML dla 429 =====
|
||||
sub vcl_synth {
|
||||
unset resp.http.X-Varnish;
|
||||
|
||||
# 429 Too Many Requests - HTML szablon
|
||||
if (resp.status == 429) {
|
||||
set resp.http.Content-Type = "text/html; charset=utf-8";
|
||||
synthetic({
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>429 - Zbyt wiele żądań</title>
|
||||
<style>
|
||||
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; margin: 0; padding: 40px; background: #f8f9fa; color: #333; text-align: center; }
|
||||
.container { max-width: 500px; margin: 0 auto; background: white; padding: 60px 40px; border-radius: 12px; box-shadow: 0 4px 20px rgba(0,0,0,0.1); }
|
||||
h1 { font-size: 72px; font-weight: 300; margin: 0 0 20px; color: #dc3545; }
|
||||
h2 { font-size: 24px; font-weight: 400; margin: 0 0 30px; color: #495057; }
|
||||
p { font-size: 16px; line-height: 1.6; margin: 0 0 20px; color: #6c757d; }
|
||||
.retry { background: #007bff; color: white; padding: 12px 30px; border: none; border-radius: 6px; font-size: 16px; cursor: pointer; text-decoration: none; display: inline-block; }
|
||||
.retry:hover { background: #0056b3; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>429</h1>
|
||||
<h2>Zbyt wiele żądań</h2>
|
||||
<p>Przekroczyłeś limit żądań. Spróbuj ponownie za chwilę.</p>
|
||||
<p><strong>Limit:</strong> 200 żądań / 10 sekund</p>
|
||||
<a href="javascript:location.reload()" class="retry">Spróbuj ponownie</a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
});
|
||||
return (deliver);
|
||||
}
|
||||
|
||||
# 405 Not Allowed
|
||||
if (resp.status == 405) {
|
||||
set resp.http.Content-Type = "text/plain; charset=utf-8";
|
||||
synthetic("Metoda PURGE dozwolona tylko z localhost");
|
||||
return (deliver);
|
||||
}
|
||||
|
||||
# PURGE success
|
||||
if (resp.status == 200 && req.method == "PURGE") {
|
||||
set resp.http.Content-Type = "text/plain; charset=utf-8";
|
||||
synthetic("Purged");
|
||||
return (deliver);
|
||||
}
|
||||
|
||||
set resp.http.X-Cache = "SYNTH";
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user