Ottomata has uploaded a new change for review.
https://gerrit.wikimedia.org/r/322964
Change subject: Allow misc directors to specify url path conditions as well as
Host conditions
......................................................................
Allow misc directors to specify url path conditions as well as Host conditions
This will allow us to be more flexible with url path based routing on misc
caches. We can now configure both a host and a url path condition when
choosing a director.
This will allow both RCStream and the new eventstreams service to be hosted
at stream.wikimedia.org. RCStream URLs all start with /rc, so we can
add a req_url_re => '^/rc' to the rcstream director config in
role::cache::misc.
Change-Id: I8d7a20060b8a1e74a272a3e23095991e869ea7dc
---
M modules/varnish/templates/misc-backend.inc.vcl.erb
1 file changed, 20 insertions(+), 1 deletion(-)
git pull ssh://gerrit.wikimedia.org:29418/operations/puppet
refs/changes/64/322964/1
diff --git a/modules/varnish/templates/misc-backend.inc.vcl.erb
b/modules/varnish/templates/misc-backend.inc.vcl.erb
index 06d168f..7b2b54f 100644
--- a/modules/varnish/templates/misc-backend.inc.vcl.erb
+++ b/modules/varnish/templates/misc-backend.inc.vcl.erb
@@ -7,11 +7,29 @@
if_stmts = []
@app_directors.keys.sort.each do |dirname|
dir = @app_directors[dirname]
+
+ # Build Host header comparison part of conditional
if dir.key?('req_host')
hostcmp = [*dir['req_host']].map { |h| %Q[req.http.Host == "#{h}"]
}.join(' || ')
else
hostcmp = %Q[req.http.Host ~ "#{dir['req_host_re']}"]
end
+
+ # Build URL path comparision part of conditional
+ if dir.key?('req_url')
+ urlcmp = [*dir['req_url']].map { |u| %Q[req.url == "#{u}"]
}.join(' || ')
+ elsif dir.key?('req_url_re')
+ urlcmp = %Q[req.url ~ "#{dir['req_url_re']}"]
+ end
+
+ # If we had a URL condition, then include it in our Host && url path
check.
+ if urlcmp
+ condition = "(#{hostcmp}) && (#{urlcmp})"
+ # else just use the hostname conditional.
+ else
+ condition = "#{hostcmp}"
+ end
+
if dir.key?('maintenance')
action = %Q[return (synth(503, "#{dir['maintenance']}"));]
else
@@ -21,7 +39,8 @@
action = "set req.backend_hint = #{dirname}.backend();\n"
end
end
- if_stmts.push("if (#{hostcmp}) {\n #{action} }")
+
+ if_stmts.push("if (#{condition}) {\n #{action} }")
end
all_ifs = if_stmts.join(' els')
%>
--
To view, visit https://gerrit.wikimedia.org/r/322964
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8d7a20060b8a1e74a272a3e23095991e869ea7dc
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Ottomata <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits