templates/varnish/site.vcl.erb in odania-0.0.31 vs templates/varnish/site.vcl.erb in odania-0.0.32
- old
+ new
@@ -8,10 +8,38 @@
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);
+ # General part
+ <% domain.get_redirects.each_pair do |src, target| %>
+ if (req.url ~ "<%= src %>") {
+ std.log("general redirect identified '<%= domain.name %>' src:'<%= src %>':" + req.url);
+ set req.http.Location = "<%= target %>";
+ return (synth(750, "Permanently moved"));
+ }
+ <% end %>
+
+ <% subdomain = domain.subdomains['_general'] %>
+ <% %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);
+
+ <% 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 %>
+
<% domain.subdomains.each_pair do |subdomain_name, subdomain|
next if '_general'.eql? subdomain_name %>
<%= 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 );
@@ -39,10 +67,13 @@
set req.http.Location = "<%= target %>";
return (synth(750, "Permanently moved"));
}
<% end %>
+ set req.backend_hint = core_backend_director.backend();
+ set req.url = "/base/identify?req_url=" + req.url + "&req_host=" + req.http.host + "&domain=<%= domain.name %>";
+ return (hash);
}
<% is_first = false %>
<% end %>
# Important: This needs to be directly after the subdomain config
@@ -50,37 +81,9 @@
# Redirect to default subdomain
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"));
}
-
- # General part
- <% domain.get_redirects.each_pair do |src, target| %>
- if (req.url ~ "<%= src %>") {
- std.log("general redirect identified '<%= domain.name %>' src:'<%= src %>':" + req.url);
- set req.http.Location = "<%= target %>";
- return (synth(750, "Permanently moved"));
- }
- <% end %>
-
- <% subdomain = domain.subdomains['_general'] %>
- <% %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);
-
- <% 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 %>
}
}
sub vcl_deliver {
if (req.http.host ~ "<%= domain.name %>$") {