Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
salt-state
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FFFFM
salt-state
Commits
c2719b5e
Commit
c2719b5e
authored
4 years ago
by
skorpy
Browse files
Options
Downloads
Patches
Plain Diff
update grafana.vcl
parent
f7a66b62
No related branches found
No related tags found
Loading
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
grafana/files/varnish-grafana.vcl.j2
+71
-8
71 additions, 8 deletions
grafana/files/varnish-grafana.vcl.j2
with
71 additions
and
8 deletions
grafana/files/varnish-grafana.vcl.j2
+
71
−
8
View file @
c2719b5e
...
...
@@ -3,18 +3,38 @@ import vsthrottle;
backend default {
{%- if frontend == 'traefik' %}
.host = "grafana";
.host = "grafana";
{%- elif frontend == 'nginx' %}
.host = "127.0.0.1";
.host = "127.0.0.1";
{%- endif %}
.port = "3000";
.port = "3000";
}
sub vcl_recv {
# Happens before we check if we have this in cache already.
# Removing Google Analytics added parameters
if(req.url ~ "(\?|&)(_t|utm_[a-z]+|mr:[A-z]+|gclid|cx|ie|cof|siteurl)=") {
set req.url = regsuball(req.url, "(_t|utm_[a-z]+|mr:[A-z]+|gclid|cx|ie|cof|siteurl)=[%.+-_A-z0-9]+&?", "");
}
set req.url = regsub(req.url, "\?&", "?");
set req.url = regsub(req.url, "(\?|&)+$", "");
if (req.method != "GET" && req.method != "HEAD") {
return (pass);
return (pass);
}
# grace period (stale content delivery while revalidating)
set req.http.grace = "none";
# Accept-Encoding header clean-up
if (req.http.Accept-Encoding) {
# use gzip when possible, otherwise use deflate
if (req.http.Accept-Encoding ~ "gzip") {
set req.http.Accept-Encoding = "gzip";
} elsif (req.http.Accept-Encoding ~ "deflate") {
set req.http.Accept-Encoding = "deflate";
} else {
unset req.http.Accept-Encoding;
}
}
# Goodbye incoming cookies:
...
...
@@ -24,10 +44,6 @@ sub vcl_recv {
unset req.http.user-agent;
unset req.http.referer;
if(req.url ~ "(\?|&)(_t|utm_[a-z]+|mr:[A-z]+)=") {
set req.url = regsuball(req.url, "(_t|utm_[a-z]+|mr:[A-z]+)=[%.+-_A-z0-9]+&?", "");
}
set req.url = regsub(req.url, "(\?|&)+$", "");
return (hash);
}
...
...
@@ -36,6 +52,35 @@ sub vcl_hash {
return(lookup);
}
sub vcl_backend_fetch {
/*
* we force keep-alive to the upstream
*/
set bereq.http.Connection = "Keep-Alive";
unset bereq.http.X-Varnish;
}
sub vcl_hit {
if (obj.ttl >= 0s) {
# normal hit
return (deliver);
}
# Looking at stale content
if (std.healthy(req.backend_hint)) {
# Backend is healthy. Limit age to 10s.
if (obj.ttl + 10s > 0s) {
set req.http.grace = "normal(limited)";
return (deliver);
} else {
# backend is sick - use full grace
if (obj.ttl + obj.grace > 0s) {
set req.http.grace = "full";
return (deliver);
}
}
}
}
sub vcl_miss {
if (req.url ~ "^/render/") {
if (vsthrottle.is_denied(req.http.X-Real-IP, 10, 30s, 10s)) {
...
...
@@ -70,4 +115,22 @@ sub vcl_deliver {
# response to the client.
#
# You can do accounting or modifying the final object here.
/*
* generic synthetic handler
*/
set resp.http.Date = now;
unset resp.http.via;
unset resp.http.x-varnish;
unset resp.http.Server;
set resp.http.Server = "nginx";
set resp.http.grace = req.http.grace;
# could be useful to know if the object was in cache or not
if (obj.hits > 0) {
set resp.http.X-Cache = "HIT";
} else {
set resp.http.X-Cache = "MISS";
}
return (deliver);
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment