templates/varnish/site.vcl.erb in odania-0.0.16 vs templates/varnish/site.vcl.erb in odania-0.0.17

- old
+ new

@@ -1,27 +1,37 @@ <% is_first = true %> vcl 4.0; # generated varnish config: <%= ENVIRONMENT %> +# local test: <%= LOCAL_TEST_MODE ? 'ENABLED' : 'DISABLED' %> sub vcl_recv { std.log("pre varnish log info '<%= domain.name %>':" + req.http.host); if (req.http.host ~ "<%= domain.name %>$") { std.log("varnish log info '<%= domain.name %>':" + req.http.host); <% domain.subdomains.each_pair do |subdomain_name, subdomain| %> <%= is_first ? '' : 'else ' %>if (req.http.host ~ "^<%= subdomain.name %>.<%= domain.name %>$") { std.log("subdomain identified '<%= subdomain.name %>.<%= domain.name %>':" + req.http.host + " url: " + req.url ); - <% subdomain.pages.each do |page| %> - if (req.url ~ "^<%= page.url %>") { - std.log("page identified '<%= subdomain.name %>.<%= domain.name %>' Page:'<%= page.url %>':" + req.url); + <% %w(direct dynamic).each do |type| %> + <% subdomain[type].each_pair do |url, page| %> + if (req.url ~ "^<%= prepare_url url %>") { + std.log("page identified '<%= subdomain.name %>.<%= domain.name %>' Page:'<%= url %>':" + req.url); - set req.backend_hint = <%= page.director %>.backend(); - <% unless page.backend_url.nil? %>set req.url = "<%= page.backend_url %>";<% end %> - } + <% if 'direct'.eql? type %> + set req.backend_hint = <%= page.director %>.backend(); + <% unless page.plugin_url.nil? %>set req.url = "<%= page.plugin_url %>";<% end %> + <% else %> + set req.backend_hint = core_backend_director.backend(); + set req.url = "/template/page?req_url=" + req.url + "&req_host=" + req.http.host + "<%= template_url_for(domain, page) %>"; + <% end %> + + return (hash); + } + <% end %> <% end %> <% subdomain.get_redirects.each_pair do |src, target| %> if (req.url ~ "<%= src %>") { std.log("redirect identified '<%= subdomain.name %>.<%= domain.name %>' src:'<%= src %>':" + req.url); @@ -32,10 +42,10 @@ } <% is_first = false %> <% end %> - else { + <%= is_first ? '' : 'else' %> { # Redirect to default std.log("varnish log info 'redirect to default':" + req.url); set req.http.Location = "http://<%= default_subdomain_for(domain) %>.<%= domain.name %>" + req.url; return (synth(750, "Permanently moved")); }