diff --git a/templates/varnish/default.vcl.erb b/templates/varnish/default.vcl.erb index 05f42a95..4d8aad62 100644 --- a/templates/varnish/default.vcl.erb +++ b/templates/varnish/default.vcl.erb @@ -1,7 +1,9 @@ # Varnish configuration file # File managed by puppet (module profile::varnish) # All modifications will be lost. vcl 4.0; +import std; + include "<%= @includes_vcl_name %>"; diff --git a/templates/varnish/vhost.vcl.erb b/templates/varnish/vhost.vcl.erb index 8e12afc0..c4351a8d 100644 --- a/templates/varnish/vhost.vcl.erb +++ b/templates/varnish/vhost.vcl.erb @@ -1,44 +1,42 @@ # vhost_<%= @servername %>.vcl # # Settings for the <%= @servername %> vhost # # File managed by puppet. All modifications will be lost. -import std; - sub vcl_recv { if ( <% @aliases.each do |alias_| -%> req.http.host ~ "^(?i)<%= Regexp.escape(alias_) %>$" || <% end -%> req.http.host ~ "^(?i)<%= Regexp.escape(@servername) %>$" ) { if (std.port(server.ip) == <%= scope['::profile::varnish::http_port'] %>) { set req.http.x-redir = "https://" + req.http.host + req.url; return(synth(850, "Moved permanently")); } <% if @vcl_recv_extra -%> <%= @vcl_recv_extra %> <% end -%> } } <% if @hsts_max_age or @vcl_deliver_extra -%> sub vcl_deliver { if ( <% @aliases.each do |alias_| -%> req.http.host ~ "^(?i)<%= Regexp.escape(alias_) %>$" || <% end -%> req.http.host ~ "^(?i)<%= Regexp.escape(@servername) %>$" ) { <% if @hsts_max_age -%> if (std.port(server.ip) != <%= scope['::profile::varnish::http_port'] %>) { set resp.http.Strict-Transport-Security = "max-age=<%= @hsts_max_age %>;"; } <% end -%> <% if @vcl_deliver_extra -%> <%= @vcl_deliver_extra %> <% end -%> } } <% end -%>