odania 0.0.32 → 0.0.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +17 -13
- data/lib/odania/config/layout.rb +9 -19
- data/lib/odania/config/page_base.rb +22 -22
- data/lib/odania/config/style.rb +2 -15
- data/lib/odania/config/sub_domain.rb +27 -19
- data/lib/odania/config.rb +1 -2
- data/lib/odania/consul.rb +10 -0
- data/lib/odania/version.rb +1 -1
- data/lib/odania.rb +0 -6
- data/odania.gemspec +1 -0
- data/spec/fixtures/global_config.json +48 -69
- data/spec/fixtures/plugin_config_1.json +35 -41
- data/spec/lib/odania/config/global_config_spec.rb +5 -3
- data/spec/lib/odania/config/plugin_config_spec.rb +4 -1
- data/spec/spec_helper.rb +1 -0
- metadata +16 -32
- data/config/varnish_config.json +0 -7
- data/features/step_definitions/varnish_steps.rb +0 -7
- data/features/varnish.feature +0 -8
- data/lib/odania/config/internal.rb +0 -58
- data/lib/odania/varnish/generators/generate_backend_vcl.rb +0 -48
- data/lib/odania/varnish/generators/generate_catch_all_vcl.rb +0 -17
- data/lib/odania/varnish/generators/generate_default_vcl.rb +0 -17
- data/lib/odania/varnish/generators/generate_final_vcl.rb +0 -17
- data/lib/odania/varnish/generators/generate_general_vcl.rb +0 -17
- data/lib/odania/varnish/generators/generate_redirects_vcl.rb +0 -18
- data/lib/odania/varnish/generators/generate_site_assets_vcl.rb +0 -14
- data/lib/odania/varnish/generators/generate_site_vcl.rb +0 -41
- data/lib/odania/varnish/generators/generate_sites_vcl.rb +0 -31
- data/lib/odania/varnish.rb +0 -92
- data/spec/lib/odania/varnish_spec.rb +0 -37
- data/templates/varnish/backend.vcl.erb +0 -51
- data/templates/varnish/catch_all.vcl.erb +0 -5
- data/templates/varnish/default.vcl.erb +0 -18
- data/templates/varnish/final.vcl.erb +0 -11
- data/templates/varnish/general.vcl.erb +0 -118
- data/templates/varnish/general_site.vcl.erb +0 -33
- data/templates/varnish/general_site_assets.vcl.erb +0 -21
- data/templates/varnish/redirects.vcl.erb +0 -12
- data/templates/varnish/site.vcl.erb +0 -93
- data/templates/varnish/site_assets.vcl.erb +0 -47
- data/templates/varnish/sites.vcl.erb +0 -11
- data/templates/varnish/websocker.vcl.erb +0 -18
@@ -1,37 +0,0 @@
|
|
1
|
-
describe Odania::Varnish do
|
2
|
-
context 'generate' do
|
3
|
-
before do
|
4
|
-
$consul_mock.service.services = {
|
5
|
-
'odania_static' => [
|
6
|
-
OpenStruct.new({
|
7
|
-
'Node' => 'agent-one',
|
8
|
-
'Address' => '172.20.20.1',
|
9
|
-
'ServiceID' => 'odania_static_1',
|
10
|
-
'ServiceName' => 'odania_static',
|
11
|
-
'ServiceTags' => [],
|
12
|
-
'ServicePort' => 80,
|
13
|
-
'ServiceAddress' => '172.20.20.1'
|
14
|
-
}),
|
15
|
-
OpenStruct.new({
|
16
|
-
'Node' => 'agent-two',
|
17
|
-
'Address' => '172.20.20.2',
|
18
|
-
'ServiceID' => 'odania_static_2',
|
19
|
-
'ServiceName' => 'odania_static',
|
20
|
-
'ServiceTags' => [],
|
21
|
-
'ServicePort' => 80,
|
22
|
-
'ServiceAddress' => '172.20.20.1'
|
23
|
-
})
|
24
|
-
]
|
25
|
-
}
|
26
|
-
end
|
27
|
-
|
28
|
-
let(:global_cfg) {
|
29
|
-
JSON.parse File.read("#{BASE_DIR}/spec/fixtures/global_config.json")
|
30
|
-
}
|
31
|
-
|
32
|
-
it 'generates the varnish config' do
|
33
|
-
$consul_mock.config.set('global_plugins_config', global_cfg)
|
34
|
-
expect(subject.generate('/tmp/varnish')).to eq("odania-varnish|odania_varnish_#{Socket.gethostname.gsub(/[^0-9a-zA-Z_]/, '_')}")
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,51 +0,0 @@
|
|
1
|
-
vcl 4.0;
|
2
|
-
# generated varnish config: <%= ENVIRONMENT %>
|
3
|
-
# local test: <%= LOCAL_TEST_MODE ? 'ENABLED' : 'DISABLED' %>
|
4
|
-
|
5
|
-
import std;
|
6
|
-
import directors;
|
7
|
-
|
8
|
-
probe www_probe {
|
9
|
-
.url = "/health";
|
10
|
-
.timeout = 1s;
|
11
|
-
.interval = <%= LOCAL_TEST_MODE ? '60s' : '4s' %>;
|
12
|
-
.window = 5;
|
13
|
-
.threshold = 3;
|
14
|
-
}
|
15
|
-
|
16
|
-
backend default {
|
17
|
-
.host = "<%= default_backend.host %>";
|
18
|
-
.port = "<%= default_backend.port %>";
|
19
|
-
.probe = www_probe;
|
20
|
-
.connect_timeout = 0.5s;
|
21
|
-
.first_byte_timeout = 20s;
|
22
|
-
.between_bytes_timeout = 5s;
|
23
|
-
.max_connections = 50;
|
24
|
-
}
|
25
|
-
|
26
|
-
<% backend_groups.each_pair do |group_name, backend_group| %>
|
27
|
-
<% backend_group.backends.each do |backend| %>
|
28
|
-
<% unless backend_name_already_taken(group_name, backend.instance_name) %>
|
29
|
-
|
30
|
-
backend <%= backend_name_for(group_name, backend.instance_name) %> {
|
31
|
-
.host = "<%= backend.host %>";
|
32
|
-
.port = "<%= backend.port %>";
|
33
|
-
.probe = www_probe;
|
34
|
-
}
|
35
|
-
<% end %>
|
36
|
-
<% end %>
|
37
|
-
<% end %>
|
38
|
-
|
39
|
-
sub vcl_init {
|
40
|
-
<% backend_groups.each_pair do |group_name, backend_group| %>
|
41
|
-
new <%= Odania.varnish_sanitize(group_name) %>_director = directors.round_robin();
|
42
|
-
<% backend_group.backends.each do |backend| %>
|
43
|
-
<%= Odania.varnish_sanitize(backend_group.name) %>_director.add_backend(<%= Odania.varnish_sanitize(group_name) %>_<%= Odania.varnish_sanitize(backend.instance_name) %>);
|
44
|
-
<% end %>
|
45
|
-
<% end %>
|
46
|
-
|
47
|
-
new core_backend_director = directors.round_robin();
|
48
|
-
<% core_backends.each do |core_backend_name| %>
|
49
|
-
core_backend_director.add_backend(<%= core_backend_name %>);
|
50
|
-
<% end %>
|
51
|
-
}
|
@@ -1,18 +0,0 @@
|
|
1
|
-
vcl 4.0;
|
2
|
-
# generated varnish config: <%= ENVIRONMENT %>
|
3
|
-
# local test: <%= LOCAL_TEST_MODE ? 'ENABLED' : 'DISABLED' %>
|
4
|
-
|
5
|
-
sub vcl_synth {
|
6
|
-
if (resp.status == 750) {
|
7
|
-
set resp.http.location = req.http.Location;
|
8
|
-
set resp.status = 301;
|
9
|
-
return (deliver);
|
10
|
-
}
|
11
|
-
}
|
12
|
-
|
13
|
-
include "/etc/varnish/backend.vcl";
|
14
|
-
include "/etc/varnish/general.vcl";
|
15
|
-
include "/etc/varnish/redirects.vcl";
|
16
|
-
include "/etc/varnish/sites.vcl";
|
17
|
-
include "/etc/varnish/catch_all.vcl";
|
18
|
-
include "/etc/varnish/final.vcl";
|
@@ -1,11 +0,0 @@
|
|
1
|
-
vcl 4.0;
|
2
|
-
# generated varnish config: <%= ENVIRONMENT %>
|
3
|
-
# local test: <%= LOCAL_TEST_MODE ? 'ENABLED' : 'DISABLED' %>
|
4
|
-
|
5
|
-
### We do not want to try anything we have not specified
|
6
|
-
### so render the 404 page via the core backend
|
7
|
-
sub vcl_recv {
|
8
|
-
set req.backend_hint = core_backend_director.backend();
|
9
|
-
set req.url = "/template/error?req_url=" + req.url + "&req_host=" + req.http.host;
|
10
|
-
return (hash);
|
11
|
-
}
|
@@ -1,118 +0,0 @@
|
|
1
|
-
<%
|
2
|
-
default_cache_time = ENVIRONMENT.eql?('production') ? '600s' : '1s'
|
3
|
-
%>
|
4
|
-
vcl 4.0;
|
5
|
-
# generated varnish config: <%= ENVIRONMENT %>
|
6
|
-
# local test: <%= LOCAL_TEST_MODE ? 'ENABLED' : 'DISABLED' %>
|
7
|
-
|
8
|
-
### Called when a client request is received
|
9
|
-
sub vcl_recv {
|
10
|
-
## Internal requests for content/partials
|
11
|
-
## we use internal.core to not have this part open to public
|
12
|
-
if (req.http.host ~ "^internal.core$") {
|
13
|
-
if (req.url ~ "^/template/content") {
|
14
|
-
std.log("template content identified! Page:" + req.url);
|
15
|
-
set req.backend_hint = core_backend_director.backend();
|
16
|
-
return (hash);
|
17
|
-
} else if (req.url ~ "^/template/partial") {
|
18
|
-
std.log("template partial identified! Page:" + req.url);
|
19
|
-
set req.backend_hint = core_backend_director.backend();
|
20
|
-
return (hash);
|
21
|
-
} else if (req.url ~ "^/template/page") {
|
22
|
-
std.log("template page identified! Page:" + req.url);
|
23
|
-
set req.backend_hint = core_backend_director.backend();
|
24
|
-
return (hash);
|
25
|
-
}
|
26
|
-
}
|
27
|
-
|
28
|
-
### always cache these items:
|
29
|
-
|
30
|
-
# varnish is alive. Get health state from core plugin.
|
31
|
-
if (req.url ~ "^/health$") {
|
32
|
-
return (hash);
|
33
|
-
}
|
34
|
-
|
35
|
-
#if (req.method == "GET" && req.url ~ "\.(js)") {
|
36
|
-
# return (hash);
|
37
|
-
#}
|
38
|
-
|
39
|
-
## images
|
40
|
-
#if (req.method == "GET" && req.url ~ "\.(gif|jpg|jpeg|bmp|png|tiff|tif|ico|img|tga|wmf)$") {
|
41
|
-
# return (hash);
|
42
|
-
#}
|
43
|
-
|
44
|
-
## various other content pages
|
45
|
-
#if (req.method == "GET" && req.url ~ "\.(css)$") {
|
46
|
-
# return (hash);
|
47
|
-
#}
|
48
|
-
|
49
|
-
## multimedia
|
50
|
-
#if (req.method == "GET" && req.url ~ "\.(svg|swf|ico|mp3|mp4|m4a|ogg|mov|avi|wmv)$") {
|
51
|
-
# return (hash);
|
52
|
-
#}
|
53
|
-
|
54
|
-
## xml
|
55
|
-
|
56
|
-
#if (req.method == "GET" && req.url ~ "\.(xml)$") {
|
57
|
-
# return (hash);
|
58
|
-
#}
|
59
|
-
}
|
60
|
-
|
61
|
-
### Called when the requested object has been retrieved from the backend, or the request to the backend has failed
|
62
|
-
### TODO: hardly changed from varnish 3. Is it still working??? Check!!!
|
63
|
-
sub vcl_backend_response {
|
64
|
-
if (bereq.method == "GET" && bereq.url ~ "\.(gif|jpg|jpeg|bmp|png|tiff|tif|ico|img|tga|wmf)$") {
|
65
|
-
unset beresp.http.set-cookie;
|
66
|
-
set beresp.ttl = <%= default_cache_time %>;
|
67
|
-
}
|
68
|
-
|
69
|
-
## various other content pages
|
70
|
-
if (bereq.method == "GET" && bereq.url ~ "\.(css)$") {
|
71
|
-
unset beresp.http.set-cookie;
|
72
|
-
set beresp.ttl = <%= default_cache_time %>;
|
73
|
-
}
|
74
|
-
|
75
|
-
if (bereq.method == "GET" && bereq.url ~ "\.(js)$") {
|
76
|
-
unset beresp.http.set-cookie;
|
77
|
-
set beresp.ttl = <%= default_cache_time %>;
|
78
|
-
}
|
79
|
-
|
80
|
-
## xml
|
81
|
-
if (bereq.method == "GET" && bereq.url ~ "\.(xml)$") {
|
82
|
-
unset beresp.http.set-cookie;
|
83
|
-
set beresp.ttl = <%= default_cache_time %>;
|
84
|
-
}
|
85
|
-
|
86
|
-
## multimedia
|
87
|
-
if (bereq.method == "GET" && bereq.url ~ "\.(svg|swf|ico|mp3|mp4|m4a|ogg|mov|avi|wmv)$") {
|
88
|
-
unset beresp.http.set-cookie;
|
89
|
-
set beresp.ttl = <%= default_cache_time %>;
|
90
|
-
}
|
91
|
-
|
92
|
-
# Allow items to be stale if needed.
|
93
|
-
set beresp.grace = 6h;
|
94
|
-
|
95
|
-
if (beresp.http.X-Do-Esi ~ "true") {
|
96
|
-
set beresp.do_esi = true;
|
97
|
-
}
|
98
|
-
|
99
|
-
<% if LOCAL_TEST_MODE %>
|
100
|
-
set beresp.ttl = 1s;
|
101
|
-
<% end %>
|
102
|
-
}
|
103
|
-
|
104
|
-
#
|
105
|
-
#
|
106
|
-
## Called before a cached object is delivered to the client
|
107
|
-
#
|
108
|
-
sub vcl_deliver {
|
109
|
-
set resp.http.X-Served-By = server.hostname;
|
110
|
-
if (obj.hits > 0) {
|
111
|
-
set resp.http.X-Cache = "HIT";
|
112
|
-
set resp.http.X-Cache-Hits = obj.hits;
|
113
|
-
} else {
|
114
|
-
set resp.http.X-Cache = "MISS";
|
115
|
-
}
|
116
|
-
|
117
|
-
return(deliver);
|
118
|
-
}
|
@@ -1,33 +0,0 @@
|
|
1
|
-
vcl 4.0;
|
2
|
-
# generated varnish config: <%= ENVIRONMENT %>
|
3
|
-
# local test: <%= LOCAL_TEST_MODE ? 'ENABLED' : 'DISABLED' %>
|
4
|
-
|
5
|
-
sub vcl_recv {
|
6
|
-
std.log("pre varnish log info _general:" + req.http.host);
|
7
|
-
|
8
|
-
<% %w(direct dynamic).each do |type| %>
|
9
|
-
<% general_subdomain[type].each_pair do |url, page| %>
|
10
|
-
if (req.url ~ "^<%= prepare_url url %>") {
|
11
|
-
std.log("general page identified Page:'<%= url %>':" + req.url);
|
12
|
-
|
13
|
-
<% if 'direct'.eql? type %>
|
14
|
-
set req.backend_hint = <%= page.director %>.backend();
|
15
|
-
<% unless page.plugin_url.nil? %>set req.url = "<%= page.plugin_url %>";<% end %>
|
16
|
-
<% else %>
|
17
|
-
set req.backend_hint = core_backend_director.backend();
|
18
|
-
set req.url = "/template/page?req_url=" + req.url + "&req_host=" + req.http.host + "<%= template_url_for(domain, page) %>";
|
19
|
-
<% end %>
|
20
|
-
|
21
|
-
return (hash);
|
22
|
-
}
|
23
|
-
<% end %>
|
24
|
-
<% end %>
|
25
|
-
|
26
|
-
<% general_subdomain.get_redirects.each_pair do |src, target| %>
|
27
|
-
if (req.url ~ "<%= src %>") {
|
28
|
-
std.log("general redirect identified src:'<%= src %>':" + req.url);
|
29
|
-
set req.http.Location = "<%= target %>";
|
30
|
-
return (synth(750, "Permanently moved"));
|
31
|
-
}
|
32
|
-
<% end %>
|
33
|
-
}
|
@@ -1,21 +0,0 @@
|
|
1
|
-
vcl 4.0;
|
2
|
-
# generated varnish config: <%= ENVIRONMENT %>
|
3
|
-
# local test: <%= LOCAL_TEST_MODE ? 'ENABLED' : 'DISABLED' %>
|
4
|
-
|
5
|
-
sub vcl_recv {
|
6
|
-
std.log("pre varnish log info '<%= domain.name %>':" + req.http.host);
|
7
|
-
if (req.http.host ~ "<%= domain.name %>$") {
|
8
|
-
std.log("varnish log info '<%= domain.name %>':" + req.http.host);
|
9
|
-
|
10
|
-
<% general_subdomain.assets.each_pair do |url, page| %>
|
11
|
-
if (req.url ~ "^<%= prepare_url url %>") {
|
12
|
-
std.log("asset identified '<%= domain.name %>' Page:'<%= url %>':" + req.url);
|
13
|
-
|
14
|
-
set req.backend_hint = <%= page.director %>.backend();
|
15
|
-
<% unless page.plugin_url.nil? %>set req.url = "<%= page.plugin_url %>";<% end %>
|
16
|
-
|
17
|
-
return (hash);
|
18
|
-
}
|
19
|
-
<% end %>
|
20
|
-
}
|
21
|
-
}
|
@@ -1,12 +0,0 @@
|
|
1
|
-
vcl 4.0;
|
2
|
-
# generated varnish config: <%= ENVIRONMENT %>
|
3
|
-
# local test: <%= LOCAL_TEST_MODE ? 'ENABLED' : 'DISABLED' %>
|
4
|
-
|
5
|
-
sub vcl_recv {
|
6
|
-
<% redirects.each_pair do |src, target| %>
|
7
|
-
if (req.http.host == "<%= src %>") {
|
8
|
-
set req.http.Location = "<%= target %>";
|
9
|
-
return (synth(750, "Permanently moved"));
|
10
|
-
}
|
11
|
-
<% end %>
|
12
|
-
}
|
@@ -1,93 +0,0 @@
|
|
1
|
-
<%
|
2
|
-
is_first = true
|
3
|
-
%>
|
4
|
-
vcl 4.0;
|
5
|
-
# generated varnish config: <%= ENVIRONMENT %>
|
6
|
-
# local test: <%= LOCAL_TEST_MODE ? 'ENABLED' : 'DISABLED' %>
|
7
|
-
|
8
|
-
sub vcl_recv {
|
9
|
-
std.log("pre varnish log info '<%= domain.name %>':" + req.http.host);
|
10
|
-
if (req.http.host ~ "<%= domain.name %>$") {
|
11
|
-
std.log("varnish log info '<%= domain.name %>':" + req.http.host);
|
12
|
-
|
13
|
-
# General part
|
14
|
-
<% domain.get_redirects.each_pair do |src, target| %>
|
15
|
-
if (req.url ~ "<%= src %>") {
|
16
|
-
std.log("general redirect identified '<%= domain.name %>' src:'<%= src %>':" + req.url);
|
17
|
-
set req.http.Location = "<%= target %>";
|
18
|
-
return (synth(750, "Permanently moved"));
|
19
|
-
}
|
20
|
-
<% end %>
|
21
|
-
|
22
|
-
<% subdomain = domain.subdomains['_general'] %>
|
23
|
-
<% %w(direct dynamic).each do |type| %>
|
24
|
-
<% subdomain[type].each_pair do |url, page| %>
|
25
|
-
if (req.url ~ "^<%= prepare_url url %>") {
|
26
|
-
std.log("page identified '<%= subdomain.name %>.<%= domain.name %>' Page:'<%= url %>':" + req.url);
|
27
|
-
|
28
|
-
<% if 'direct'.eql? type %>
|
29
|
-
set req.backend_hint = <%= page.director %>.backend();
|
30
|
-
<% unless page.plugin_url.nil? %>set req.url = "<%= page.plugin_url %>";<% end %>
|
31
|
-
<% else %>
|
32
|
-
set req.backend_hint = core_backend_director.backend();
|
33
|
-
set req.url = "/template/page?req_url=" + req.url + "&req_host=" + req.http.host + "<%= template_url_for(domain, page) %>";
|
34
|
-
<% end %>
|
35
|
-
|
36
|
-
return (hash);
|
37
|
-
}
|
38
|
-
<% end %>
|
39
|
-
<% end %>
|
40
|
-
|
41
|
-
<% domain.subdomains.each_pair do |subdomain_name, subdomain|
|
42
|
-
next if '_general'.eql? subdomain_name %>
|
43
|
-
<%= is_first ? '' : 'else ' %>if (req.http.host ~ "^<%= subdomain.name %>.<%= domain.name %>$") {
|
44
|
-
std.log("subdomain identified '<%= subdomain.name %>.<%= domain.name %>':" + req.http.host + " url: " + req.url );
|
45
|
-
|
46
|
-
<% %w(direct dynamic).each do |type| %>
|
47
|
-
<% subdomain[type].each_pair do |url, page| %>
|
48
|
-
if (req.url ~ "^<%= prepare_url url %>") {
|
49
|
-
std.log("page identified '<%= subdomain.name %>.<%= domain.name %>' Page:'<%= url %>':" + req.url);
|
50
|
-
|
51
|
-
<% if 'direct'.eql? type %>
|
52
|
-
set req.backend_hint = <%= page.director %>.backend();
|
53
|
-
<% unless page.plugin_url.nil? %>set req.url = "<%= page.plugin_url %>";<% end %>
|
54
|
-
<% else %>
|
55
|
-
set req.backend_hint = core_backend_director.backend();
|
56
|
-
set req.url = "/template/page?req_url=" + req.url + "&req_host=" + req.http.host + "<%= template_url_for(domain, page) %>";
|
57
|
-
<% end %>
|
58
|
-
|
59
|
-
return (hash);
|
60
|
-
}
|
61
|
-
<% end %>
|
62
|
-
<% end %>
|
63
|
-
|
64
|
-
<% subdomain.get_redirects.each_pair do |src, target| %>
|
65
|
-
if (req.url ~ "<%= src %>") {
|
66
|
-
std.log("redirect identified '<%= subdomain.name %>.<%= domain.name %>' src:'<%= src %>':" + req.url);
|
67
|
-
set req.http.Location = "<%= target %>";
|
68
|
-
return (synth(750, "Permanently moved"));
|
69
|
-
}
|
70
|
-
<% end %>
|
71
|
-
|
72
|
-
set req.backend_hint = core_backend_director.backend();
|
73
|
-
set req.url = "/base/identify?req_url=" + req.url + "&req_host=" + req.http.host + "&domain=<%= domain.name %>";
|
74
|
-
return (hash);
|
75
|
-
}
|
76
|
-
<% is_first = false %>
|
77
|
-
<% end %>
|
78
|
-
|
79
|
-
# Important: This needs to be directly after the subdomain config
|
80
|
-
<%= is_first ? '' : 'else' %> {
|
81
|
-
# Redirect to default subdomain
|
82
|
-
std.log("varnish log info 'redirect to default':" + req.url);
|
83
|
-
set req.http.Location = "http://<%= default_subdomain_for(domain) %>.<%= domain.name %>" + req.url;
|
84
|
-
return (synth(750, "Permanently moved"));
|
85
|
-
}
|
86
|
-
}
|
87
|
-
}
|
88
|
-
|
89
|
-
sub vcl_deliver {
|
90
|
-
if (req.http.host ~ "<%= domain.name %>$") {
|
91
|
-
# What to do?
|
92
|
-
}
|
93
|
-
}
|
@@ -1,47 +0,0 @@
|
|
1
|
-
<%
|
2
|
-
is_first = true
|
3
|
-
%>
|
4
|
-
vcl 4.0;
|
5
|
-
# generated varnish config: <%= ENVIRONMENT %>
|
6
|
-
# local test: <%= LOCAL_TEST_MODE ? 'ENABLED' : 'DISABLED' %>
|
7
|
-
|
8
|
-
sub vcl_recv {
|
9
|
-
std.log("pre varnish log info '<%= domain.name %>':" + req.http.host);
|
10
|
-
if (req.http.host ~ "<%= domain.name %>$") {
|
11
|
-
std.log("varnish log info '<%= domain.name %>':" + req.http.host);
|
12
|
-
|
13
|
-
# subdomains
|
14
|
-
<% domain.subdomains.each_pair do |subdomain_name, subdomain| %>
|
15
|
-
<% next if '_general'.eql? subdomain_name %>
|
16
|
-
<%= is_first ? '' : 'else ' %>if (req.http.host ~ "^<%= subdomain.name %>.<%= domain.name %>$") {
|
17
|
-
std.log("subdomain identified '<%= subdomain.name %>.<%= domain.name %>':" + req.http.host + " url: " + req.url );
|
18
|
-
|
19
|
-
<% subdomain.assets.each_pair do |url, page| %>
|
20
|
-
if (req.url ~ "^<%= prepare_url url %>") {
|
21
|
-
std.log("page identified '<%= subdomain.name %>.<%= domain.name %>' Page:'<%= url %>':" + req.url);
|
22
|
-
|
23
|
-
set req.backend_hint = <%= page.director %>.backend();
|
24
|
-
<% unless page.plugin_url.nil? %>set req.url = "<%= page.plugin_url %>";<% end %>
|
25
|
-
|
26
|
-
return (hash);
|
27
|
-
}
|
28
|
-
<% end %>
|
29
|
-
|
30
|
-
}
|
31
|
-
<% is_first = false %>
|
32
|
-
<% end %>
|
33
|
-
|
34
|
-
# general
|
35
|
-
<% subdomain = domain.subdomain('_general') %>
|
36
|
-
<% subdomain.assets.each_pair do |url, page| %>
|
37
|
-
if (req.url ~ "^<%= prepare_url url %>") {
|
38
|
-
std.log("page identified '<%= subdomain.name %>.<%= domain.name %>' Page:'<%= url %>':" + req.url);
|
39
|
-
|
40
|
-
set req.backend_hint = <%= page.director %>.backend();
|
41
|
-
<% unless page.plugin_url.nil? %>set req.url = "<%= page.plugin_url %>";<% end %>
|
42
|
-
|
43
|
-
return (hash);
|
44
|
-
}
|
45
|
-
<% end %>
|
46
|
-
}
|
47
|
-
}
|
@@ -1,11 +0,0 @@
|
|
1
|
-
vcl 4.0;
|
2
|
-
# generated varnish config: <%= ENVIRONMENT %>
|
3
|
-
# local test: <%= LOCAL_TEST_MODE ? 'ENABLED' : 'DISABLED' %>
|
4
|
-
|
5
|
-
# @see https://www.varnish-cache.org/lists/pipermail/varnish-misc/2011-January/005449.html
|
6
|
-
|
7
|
-
# Sites
|
8
|
-
<% domains.each_pair do |domain_name, domain| %>
|
9
|
-
include "/etc/varnish/sites/<%= domain_name %>_assets.vcl";
|
10
|
-
include "/etc/varnish/sites/<%= domain_name %>.vcl";
|
11
|
-
<% end %>
|
@@ -1,18 +0,0 @@
|
|
1
|
-
vcl 4.0;
|
2
|
-
# generated varnish config: <%= ENVIRONMENT %>
|
3
|
-
# local test: <%= LOCAL_TEST_MODE ? 'ENABLED' : 'DISABLED' %>
|
4
|
-
# https://www.varnish-cache.org/docs/4.0/users-guide/vcl-example-websockets.html
|
5
|
-
|
6
|
-
sub vcl_pipe {
|
7
|
-
if (req.http.upgrade)
|
8
|
-
{
|
9
|
-
set bereq.http.upgrade = req.http.upgrade;
|
10
|
-
}
|
11
|
-
}
|
12
|
-
|
13
|
-
sub vcl_recv {
|
14
|
-
if (req.http.Upgrade ~"(?i)websocket")
|
15
|
-
{
|
16
|
-
return (pipe);
|
17
|
-
}
|
18
|
-
}
|