Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
varnish
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ansible
Roles
varnish
Commits
ea3e0977
Commit
ea3e0977
authored
8 years ago
by
jurgenhaas
Browse files
Options
Downloads
Patches
Plain Diff
ansible-inventories/arocom#163 Configure HaProxy and Varnish to also handle BAN requests on port 80
parent
a40b6dcc
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
templates/default.vcl
+19
-4
19 additions, 4 deletions
templates/default.vcl
with
19 additions
and
4 deletions
templates/default.vcl
+
19
−
4
View file @
ea3e0977
...
...
@@ -63,14 +63,29 @@ sub vcl_recv {
unset
req.http.proxy
;
# Allow purging
if
(
req.method
==
"PURGE"
)
{
if
(
req.method
==
"PURGE"
||
req.method
==
"BAN"
)
{
# Make sure that HaProxy has been setting the header value x-real-ip properly
if
(
!
std.ip
(
req.http.x-real-ip
,
"0.0.0.0"
)
~
purge
)
{
# purge is the ACL defined at the beginning
# Not from an allowed IP? Then die with an error.
return
(
synth
(
405
,
"This IP is not allowed to send PURGE requests."
));
return
(
synth
(
405
,
"This IP is not allowed to send PURGE
or BAN
requests."
));
}
# If you got this stage (and didn't error out above), purge the cached result
return
(
purge
);
if
(
req.method
==
"PURGE"
)
{
# If you got this stage (and didn't error out above), purge the cached result
return
(
purge
);
}
# Logic for the ban, using the Purge-Cache-Tags header. For more info
# see https://github.com/geerlingguy/drupal-vm/issues/397.
if
(
req.http.Purge-Cache-Tags
)
{
ban
(
"obj.http.Purge-Cache-Tags ~ "
+
req.http.Purge-Cache-Tags
);
}
else
{
return
(
synth
(
403
,
"Purge-Cache-Tags header missing."
));
}
# Throw a synthetic page so the request won't go to the backend.
return
(
synth
(
200
,
"Ban added."
));
}
# Only deal with "normal" types
...
...
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