Update info.
This commit is contained in:
@@ -2,9 +2,6 @@ vcl 4.1;
|
|||||||
|
|
||||||
# https://github.com/varnish/toolbox/tree/master/vcls/hit-miss
|
# https://github.com/varnish/toolbox/tree/master/vcls/hit-miss
|
||||||
include "hit-miss.vcl";
|
include "hit-miss.vcl";
|
||||||
|
|
||||||
# import vmod_dynamic for better backend name resolution
|
|
||||||
import dynamic;
|
|
||||||
import std;
|
import std;
|
||||||
|
|
||||||
backend default {
|
backend default {
|
||||||
@@ -19,6 +16,12 @@ acl purge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub vcl_recv {
|
sub vcl_recv {
|
||||||
|
set req.http.Host = regsub(req.http.Host, ":[0-9]+", "");
|
||||||
|
unset req.http.proxy;
|
||||||
|
set req.url = std.querysort(req.url);
|
||||||
|
set req.url = regsub(req.url, "\?$", "");
|
||||||
|
set req.http.Surrogate-Capability = "key=ESI/1.0";
|
||||||
|
|
||||||
if (req.url ~ "/purge-cache") {
|
if (req.url ~ "/purge-cache") {
|
||||||
if (!client.ip ~ purge) {
|
if (!client.ip ~ purge) {
|
||||||
return(synth(403, "Not allowed."));
|
return(synth(403, "Not allowed."));
|
||||||
@@ -26,9 +29,17 @@ sub vcl_recv {
|
|||||||
ban("req.http.host == rstat.net");
|
ban("req.http.host == rstat.net");
|
||||||
return(synth(200, "Cache cleared"));
|
return(synth(200, "Cache cleared"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!req.http.X-Forwarded-Proto) {
|
||||||
|
if(std.port(server.ip) == 443 || std.port(server.ip) == 8443) {
|
||||||
|
set req.http.X-Forwarded-Proto = "https";
|
||||||
|
} else {
|
||||||
|
set req.http.X-Forwarded-Proto = "https";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# Cache static files
|
# Cache static files
|
||||||
if (req.url ~ "\.(css|js|avif|webp|png|jpe?g|gif|ico|svg|woff2?|eot|ttf|otf|json|csv|pdf|mp4|webm|ogg|mp3|wav|flac)$") {
|
if (req.url ~ "^[^?]*\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|ico|jpeg|jpg|js|less|mka|mkv|mov|mp3|mp4|mpeg|mpg|odt|ogg|ogm|opus|otf|pdf|png|ppt|pptx|rar|rtf|svg|svgz|swf|tar|tbz|tgz|ttf|txt|txz|wav|webm|webp|woff|woff2|xls|xlsx|xml|xz|zip)(\?.*)?$") {
|
||||||
unset req.http.Cookie;
|
unset req.http.Cookie;
|
||||||
return(hash);
|
return(hash);
|
||||||
}
|
}
|
||||||
@@ -38,6 +49,10 @@ sub vcl_recv {
|
|||||||
return(hash);
|
return(hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub vcl_hash {
|
||||||
|
hash_data(req.http.X-Forwarded-Proto);
|
||||||
|
}
|
||||||
|
|
||||||
sub vcl_backend_response {
|
sub vcl_backend_response {
|
||||||
# Cache static files and other content in Varnish for 1 year
|
# Cache static files and other content in Varnish for 1 year
|
||||||
set beresp.ttl = 1m;
|
set beresp.ttl = 1m;
|
||||||
|
Reference in New Issue
Block a user