Skip to content

Commit

Permalink
Add prepend and append sections for sub vcl_deliver
Browse files Browse the repository at this point in the history
  • Loading branch information
Emerson Prado committed Sep 29, 2017
1 parent e11bf05 commit 2e662c3
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions templates/varnish4-vcl.erb
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ sub vcl_recv {
<%- end -%>
<%- if @logrealip -%>
if (req.http.X-Forwarded-For) {
std.log("RealIP:" + req.http.X-Forwarded-For);
std.log("RealIP:" + req.http.X-Forwarded-For);
} else {
std.log("RealIP:" + client.ip);
std.log("RealIP:" + client.ip);
}
<%- end -%>

Expand Down Expand Up @@ -64,7 +64,7 @@ sub vcl_recv {
# Static file cache
((req.url ~ "(?i)\.(jpg|jpeg|gif|png|tiff|tif|svg|swf|ico|css|kss|js|vsd|doc|ppt|pps|xls|pdf|mp3|mp4|m4a|ogg|mov|avi|wmv|sxw|zip|gz|bz2|tar|rar|odc|odb|odf|odg|odi|odp|ods|odt|sxc|sxd|sxi|sxw|dmg|torrent|deb|msi|iso|rpm|jar|class|flv|exe)$")||
# Plone images cache
(req.url ~ "(?i)(image|imagem_large|image_preview|image_mini|image_thumb|image_tile|image_icon|imagem_listing)$")) &&
(req.url ~ "(?i)(image|imagem_large|image_preview|image_mini|image_thumb|image_tile|image_icon|imagem_listing)$")) &&
# Plone resource editor
(req.url !~ "(?i)\@\@plone\.resourceeditor\.getfile\?path\=")
<%- end -%>
Expand Down Expand Up @@ -107,7 +107,7 @@ sub vcl_recv {
return (synth(405, "Not allowed."));
}
ban(" req.url == " + req.url);
set req.url = regsuball(req.url,"80","443");
set req.url = regsuball(req.url,"80","443");
set req.url = regsuball(req.url,"http","https");
ban(" req.url == " + req.url);
# Throw a synthetic page so the
Expand Down Expand Up @@ -230,6 +230,9 @@ sub vcl_deliver {
<%- if @functions['vcl_deliver'] -%>
<%= @functions.delete('vcl_deliver') %>
<%- else -%>
<%- if @functions['vcl_deliver_prepend'] -%>
<%= @functions.delete('vcl_deliver_prepend') %>
<%- end -%>
if (obj.hits > 0) {
set resp.http.X-Cache = "HIT";
} else {
Expand All @@ -247,6 +250,9 @@ sub vcl_deliver {
}
<%-end-%>
<%-end-%>
<%- if @functions['vcl_deliver_append'] -%>
<%= @functions.delete('vcl_deliver_append') %>
<%- end -%>
<%-end-%>
}

Expand Down

0 comments on commit 2e662c3

Please sign in to comment.