Ori.livneh has submitted this change and it was merged.
Change subject: VCL: Standardize on '//'-style comments
......................................................................
VCL: Standardize on '//'-style comments
VCL supports /* */, #, and //. I consider multi-line comments problematic
because in the absence of reliable syntax highlighting they can conceal the
fact that code is commented out, and because you cannot safely move lines
around. Most modern editing environments allow you to comment/uncomment a whole
block of code using '//' with a few keystrokes (e.g., 'gc' in VIM).
'#' comments are not safe for inline C code.
Change-Id: I12f4495dbad33c4b30611df27830d1033f6d441a
---
M templates/varnish/bits.inc.vcl.erb
M templates/varnish/geoip.inc.vcl.erb
M templates/varnish/misc.inc.vcl.erb
M templates/varnish/mobile-backend.inc.vcl.erb
M templates/varnish/mobile-frontend.inc.vcl.erb
M templates/varnish/parsoid-backend.inc.vcl.erb
M templates/varnish/parsoid-common.inc.vcl.erb
M templates/varnish/parsoid-frontend.inc.vcl.erb
M templates/varnish/text-backend.inc.vcl.erb
M templates/varnish/text-common.inc.vcl.erb
M templates/varnish/text-frontend.inc.vcl.erb
M templates/varnish/upload-backend.inc.vcl.erb
M templates/varnish/upload-frontend.inc.vcl.erb
M templates/varnish/zero.inc.vcl.erb
14 files changed, 148 insertions(+), 162 deletions(-)
Approvals:
Ori.livneh: Verified; Looks good to me, approved
diff --git a/templates/varnish/bits.inc.vcl.erb
b/templates/varnish/bits.inc.vcl.erb
index 5bd23e5..132856b 100644
--- a/templates/varnish/bits.inc.vcl.erb
+++ b/templates/varnish/bits.inc.vcl.erb
@@ -1,18 +1,17 @@
-# Varnish VCL include file for bits
+// Varnish VCL include file for bits
include "errorpage.inc.vcl";
<% if @vcl_config.fetch("cluster_tier", "1") == "1" -%>
sub mangle_request {
- /* transform backend url: /<sitename>/load.php -> /w/load.php
- set host header for backend to <sitename>
- */
+ // Transform backend url: /<sitename>/load.php -> /w/load.php
+ // Set host header for backend to <sitename>
if (req.url ~
"^/([a-zA-Z0-9-]+\.)?([a-zA-Z0-9-]+\.)?([a-zA-Z0-9-]+)\.<%=
Regexp.escape(@cluster_options.fetch("top_domain", "org")) %>/load\.php") {
set bereq.http.host = regsub(req.url, "^/([^/]+)/(.*)$", "\1");
set bereq.url = regsub(req.url, "^/([^/]+)/load\.php(.*)?",
"/w/load.php\2");
<% if @cluster_options.fetch("test_hostname", false) -%>
- # Send test.wikipedia.org to the right backend server
+ // Send test.wikipedia.org to the right backend server
if (req.url ~ "^/<%=
Regexp.escape(@cluster_options.fetch("test_hostname")) %>/load\.php") {
set req.backend = test_wikipedia;
}
@@ -39,9 +38,9 @@
}
if (req.http.host == "<%= @cluster_options.fetch("bits_domain",
"bits.wikimedia.org") %>") {
- /* For https-only wikis, the redirect from http to https for bits
assets should occur
- in varnish instead of apache, since the apache redirect and
mediawiki doesn't
- vary by protocol. This can result in a redirect loop and assets
not loading. */
+ // For https-only wikis, the redirect from http to https for
bits assets should occur
+ // in varnish instead of apache, since the apache redirect and
mediawiki doesn't
+ // vary by protocol. This can result in a redirect loop and
assets not loading.
if (req.url ~
"^/(auditcom|boardgovcom|board|chair|chapcom|checkuser|collab|donate|exec|fdc|grants|internal|movementroles|nomcom|office|otrs-wiki|searchcom|spcom|steward|wikimaniateam)\.wikimedia\.org/"
&& req.http.X-Forwarded-Proto != "https") {
error 301 "https://<%=
@cluster_options.fetch("bits_domain", "bits.wikimedia.org") %>" + req.url;
}
@@ -67,16 +66,14 @@
}
sub vcl_fetch {
- /*
- Do not serialize calls for non-cachable objects.
- Removing this would break debug=true in mediawiki.
- */
+ // Do not serialize calls for non-cachable objects.
+ // Removing this would break debug=true in mediawiki.
if (beresp.ttl <= 0s) {
set beresp.ttl = 120s;
return (hit_for_pass);
}
- /* Don't run the default vcl_fetch function */
+ // Don't run the default vcl_fetch function
return (deliver);
}
@@ -87,11 +84,9 @@
<% end -%>
<% if @vcl_config.fetch("cluster_tier", "1") == "1" -%>
-/*
- vcl_pass gets called by hit_for_pass objects in place of vcl_miss, so
- we need to mangle the request object here as well. Actually, vcl_miss
- and vcl_pass should probably be identical for the time being.
-*/
+// vcl_pass gets called by hit_for_pass objects in place of vcl_miss, so
+// we need to mangle the request object here as well. Actually, vcl_miss
+// and vcl_pass should probably be identical for the time being.
sub vcl_pass {
call mangle_request;
}
@@ -99,7 +94,7 @@
sub vcl_error {
<% if @cluster_options.fetch("enable_geoiplookup", false) -%>
- /* Support geoiplookup */
+ // Support geoiplookup
if (obj.status == 666) {
call geoip_lookup;
set obj.status = 200;
@@ -107,12 +102,12 @@
return (deliver);
}
<% end -%>
- /* 204 responses shouldn't contain a body */
+ // 204 responses shouldn't contain a body
if (obj.status == 204) {
set obj.http.Connection = "keep-alive";
return (deliver);
}
- /* 301 redirects for https-only wikis */
+ // 301 redirects for https-only wikis
if (obj.status == 301) {
set obj.http.Location = obj.response;
set obj.status = 301;
diff --git a/templates/varnish/geoip.inc.vcl.erb
b/templates/varnish/geoip.inc.vcl.erb
index 083287c..74915d1 100644
--- a/templates/varnish/geoip.inc.vcl.erb
+++ b/templates/varnish/geoip.inc.vcl.erb
@@ -1,8 +1,8 @@
-# Varnish VCL include file
+// Varnish VCL include file
-# Note: This requires "import header" in the including VCL
+// Note: This requires "import header" in the including VCL
-# init GeoIP code
+// Init GeoIP code
C{
#include <dlfcn.h>
#include <stdlib.h>
@@ -123,9 +123,9 @@
}
}
- /* If either the second- or top-level domain is less than three
characters long, */
- /* assume that the domain uses a two-part public suffix (like
'.co.uk') and include */
- /* one additional level in the result.
*/
+ // If either the second- or top-level domain is less than three
characters long,
+ // assume that the domain uses a two-part public suffix (like
'.co.uk') and include
+ // one additional level in the result.
if ((pos - last) <= 3 || (last - second_last) <= 3) {
top_cookie_domain = third_last;
} else {
@@ -206,7 +206,7 @@
int snp_len;
if (record) {
- /* Set-Cookie:
GeoIP=US:San_Francisco:37.7749:-122.4194:v4; path=/ */
+ // Set-Cookie:
GeoIP=US:San_Francisco:37.7749:-122.4194:v4; path=/
snp_len = snprintf(cookie_buf, sizeof(cookie_buf),
"GeoIP=%s:%s:%.4f:%.4f:%s",
record->country_code ? record->country_code :
"",
record->city ? record->city : "",
@@ -219,12 +219,12 @@
snp_len = snprintf(cookie_buf, sizeof(cookie_buf),
"GeoIP=::::%s", (strchr(ip, ':') != NULL) ? "v6" : "v4");
}
- /* don't use snprintf()-truncated output */
+ // don't use snprintf()-truncated output
if (snp_len < sizeof(cookie_buf)) {
geo_sanitize_for_cookie(cookie_buf);
- /* Use libvmod-header to ensure the Set-Cookie header
we are adding does not
- clobber or manipulate existing cookie headers (if
any). */
+ // Use libvmod-header to ensure the Set-Cookie header
we are adding does not
+ // clobber or manipulate existing cookie headers (if
any).
Vmod_Func_header.append(sp, HDR_RESP,
"\013Set-Cookie:", cookie_buf, "; Path=/; Domain=.",
host_safe, vrt_magic_string_end);
}
diff --git a/templates/varnish/misc.inc.vcl.erb
b/templates/varnish/misc.inc.vcl.erb
index b1166b3..94a4b4a 100644
--- a/templates/varnish/misc.inc.vcl.erb
+++ b/templates/varnish/misc.inc.vcl.erb
@@ -3,7 +3,7 @@
sub vcl_recv {
if (req.http.Host == "git.wikimedia.org") {
set req.backend = antimony;
- /* gitblit requires the following request headers: */
+ // gitblit requires the following request headers:
set req.http.X-Forwarded-Proto = "https";
set req.http.X-Forwarded-Port = "443";
} elsif (req.http.Host == "doc.wikimedia.org" || req.http.Host ==
"integration.wikimedia.org") {
@@ -12,7 +12,7 @@
set req.backend = dataset1001;
} elsif (req.http.Host == "gerrit.wikimedia.org") {
set req.backend = ytterbium;
- /* no caching */
+ // No caching
return (pass);
} elsif (req.http.Host == "gdash.wikimedia.org" || req.http.Host ==
"graphite.wikimedia.org" || req.http.Host == "performance.wikimedia.org") {
set req.backend = tungsten;
@@ -37,7 +37,7 @@
set req.backend = antimony;
} elsif (req.http.Host == "people.wikimedia.org") {
set req.backend = terbium;
- /* no caching of public_html dirs */
+ // No caching of public_html dirs
return (pass);
} elsif (req.http.Host == "ishmael.wikimedia.org") {
set req.backend = neon;
@@ -47,7 +47,7 @@
set req.backend = stat1001;
} elsif (req.http.Host == "config-master.wikimedia.org") {
set req.backend = palladium;
- /* no caching of configs; scripts may want to know when things
change */
+ // No caching of configs; scripts may want to know when things
change
return (pass);
} elsif (req.http.Host == "noc.wikimedia.org") {
set req.backend = terbium;
@@ -60,7 +60,7 @@
}
if (req.request != "GET" && req.request != "HEAD") {
- /* We only deal with GET and HEAD */
+ // We only deal with GET and HEAD
return (pass);
}
diff --git a/templates/varnish/mobile-backend.inc.vcl.erb
b/templates/varnish/mobile-backend.inc.vcl.erb
index d56d101..7e72ce6 100644
--- a/templates/varnish/mobile-backend.inc.vcl.erb
+++ b/templates/varnish/mobile-backend.inc.vcl.erb
@@ -1,10 +1,10 @@
-# Varnish VCL include file for mobile backends
+// Varnish VCL include file for mobile backends
include "errorpage.inc.vcl";
sub vcl_recv {
call vcl_recv_purge;
- /* FIXME: restrict access */
+ // FIXME: restrict access
if (req.http.host ~ "^test\.") {
<% if @vcl_config.fetch("cluster_tier", "1") == "1" -%>
@@ -18,13 +18,13 @@
}
<% end -%>
- /* Default (now modified) Varnish vcl_recv function */
+ // Default (now modified) Varnish vcl_recv function
if (req.request != "GET" && req.request != "HEAD") {
- /* We only deal with GET and HEAD by default */
+ // We only deal with GET and HEAD by default
return (pass);
}
if (req.http.Authorization || req.http.Cookie) {
- /* Not cacheable by default */
+ // Not cacheable by default
return (pass);
}
return (lookup);
diff --git a/templates/varnish/mobile-frontend.inc.vcl.erb
b/templates/varnish/mobile-frontend.inc.vcl.erb
index 5a84b72..d6502a7 100644
--- a/templates/varnish/mobile-frontend.inc.vcl.erb
+++ b/templates/varnish/mobile-frontend.inc.vcl.erb
@@ -1,4 +1,4 @@
-# Varnish VCL include file for mobile frontends
+// Varnish VCL include file for mobile frontends
include "errorpage.inc.vcl";
include "zero.inc.vcl";
@@ -22,7 +22,7 @@
error 403 "Noise";
}
- /* Forged UAs on zerodot. This largely handles lazywebtools below,
incidentally. */
+ // Forged UAs on zerodot. This largely handles lazywebtools below,
incidentally.
if (req.http.host ~ "zero\.wikipedia\.org" && req.http.User-Agent &&
req.http.User-Agent ~ "Facebookbot|Googlebot") {
error 403 "Noise";
}
@@ -35,9 +35,8 @@
sub vcl_recv {
call filter_noise;
- /* FIXME: we're seeing an issue with Range requests and gzip/gunzip.
- * Disable Range requests for now.
- */
+ // FIXME: we're seeing an issue with Range requests and gzip/gunzip.
+ // Disable Range requests for now.
unset req.http.Range;
// Only do tag_carrier logic on first start, and only for (m|zero).wp
@@ -54,7 +53,7 @@
}
}
- /* Rewrite m.mediawiki.org to mediawiki.org etc */
+ // Rewrite m.mediawiki.org to mediawiki.org etc
if (req.http.host == "m.mediawiki.org") {
set req.http.host = "www.mediawiki.org";
} else if (req.http.host == "m.wikimediafoundation.org") {
@@ -63,33 +62,32 @@
set req.http.host = "wikisource.org";
} else {
- /* Replace <language>.(m|zero).<project>.org by
<language>.<project>.org */
+ // Replace <language>.(m|zero).<project>.org by
<language>.<project>.org
set req.http.host = regsub(req.http.host,
"^([a-zA-Z0-9-]+)\.(m|zero)\.", "\1.");
- /* Rewrite <language>.wap.wikipedia.org to new mobile site */
+ // Rewrite <language>.wap.wikipedia.org to new mobile site
set req.http.host = regsub(req.http.host,
"^([a-zA-Z0-9-]+)\.wap\.", "\1.mobile.");
- /* Support the old mobile.wikipedia.org wap gateway */
+ // Support the old mobile.wikipedia.org wap gateway
if (req.http.host ~
"^([a-zA-Z0-9-]+)\.mobile\.([a-zA-Z0-9-]+)\.org$") {
set req.http.host = regsub(req.http.host,
"^([a-zA-Z0-9-]+)\.mobile\.", "\1.");
set req.url = regsub(req.url, "\S+[\?&]go=([^&]+).*",
"/wiki/\1");
}
}
- /* Allow purging */
+ // Allow purging
call vcl_recv_purge;
call rewrite_proxy_urls;
- /* FIXME: deploy X-Vary-Options support */
+ // FIXME: deploy X-Vary-Options support
set req.http.X-Orig-Cookie = req.http.Cookie;
if (req.http.Cookie ~ "disable" ||
req.http.Cookie ~ "optin" ||
req.http.Cookie ~ "[Ss]ession" ||
req.http.Cookie ~ "forceHTTPS") {
- /* Do nothing; these are the cookies we pass.
- * this is a hack in the absence of X-V-O support
- */
+ // Do nothing; these are the cookies we pass.
+ // this is a hack in the absence of X-V-O support
} else {
unset req.http.Cookie;
}
@@ -107,13 +105,13 @@
}
<% end -%>
- /* Default (now modified) Varnish vcl_recv function */
+ // Default (now modified) Varnish vcl_recv function
if (req.request != "GET" && req.request != "HEAD") {
- /* We only deal with GET and HEAD by default */
+ // We only deal with GET and HEAD by default
return (pass);
}
if (req.http.Authorization || req.http.Cookie) {
- /* Not cacheable by default */
+ // Not cacheable by default
return (pass);
}
return (lookup);
@@ -140,7 +138,7 @@
}
sub vcl_error {
- /* Support mobile redirects */
+ // Support mobile redirects
if (obj.status == 666) {
set obj.http.Location = obj.response;
set obj.status = 302;
@@ -155,10 +153,9 @@
sub vcl_deliver {
# unset resp.http.Enable-ESI;
- /* Assemble X-Analytics header
- Some of the headers used for X-Analytics are not varied on, so add
them after the backend processing
- Note that vcl_deliver in other files may also modify X-Analytics.
- */
+ // Assemble X-Analytics header
+ // Some of the headers used for X-Analytics are not varied on, so add
them after the backend processing
+ // Note that vcl_deliver in other files may also modify X-Analytics.
if (req.http.X-Forwarded-Proto) {
if (resp.http.X-Analytics) {
set resp.http.X-Analytics = resp.http.X-Analytics +
";https=1";
@@ -181,14 +178,14 @@
set resp.http.Cache-Control = "private, s-maxage=0, max-age=0,
must-revalidate";
}
- /* Temp test */
+ // Temp test
if (req.url == "/favicon.ico" || req.url ~
"^/apple-touch-icon(-precomposed)?\.png$" || req.url ~
"^/w/index\.php\?title=.*:Gadget-.*&[0-9]+$") {
set resp.http.Cache-Control = "s-maxage=3600, max-age=3600";
}
- /* TODO: this block of VCL code is copypasta from text-frontend. Some
consolidation is in order. */
+ // TODO: this block of VCL code is copypasta from text-frontend. Some
consolidation is in order.
<% if @cluster_options.fetch("enable_geoiplookup", false) -%>
- /* Perform GeoIP look-up and send the result as a session
cookie */
+ // Perform GeoIP look-up and send the result as a session cookie
if (req.http.X-Orig-Cookie !~ "(^|;\s*)GeoIP=[^;]"
&& req.http.Orig-Cookie !~ "(^|;\s*)GeoIP=[^;]"
&& req.http.Cookie !~ "(^|;\s*)GeoIP=[^;]") {
diff --git a/templates/varnish/parsoid-backend.inc.vcl.erb
b/templates/varnish/parsoid-backend.inc.vcl.erb
index e0793ef..bf17d454 100644
--- a/templates/varnish/parsoid-backend.inc.vcl.erb
+++ b/templates/varnish/parsoid-backend.inc.vcl.erb
@@ -1,6 +1,6 @@
-# Varnish VCL include file for Parsoid backends
+// Varnish VCL include file for Parsoid backends
-# Include common Parsoid config shared between front- and backend
+// Include common Parsoid config shared between front- and backend
include "parsoid-common.inc.vcl";
sub vcl_miss {
diff --git a/templates/varnish/parsoid-common.inc.vcl.erb
b/templates/varnish/parsoid-common.inc.vcl.erb
index cc12745..a6e9868 100644
--- a/templates/varnish/parsoid-common.inc.vcl.erb
+++ b/templates/varnish/parsoid-common.inc.vcl.erb
@@ -1,14 +1,14 @@
-# Varnish VCL include file shared between Parsoid front- and backends
+// Varnish VCL include file shared between Parsoid front- and backends
sub vcl_recv {
if (req.http.Host ~ "cxserver" ) {
set req.backend = cxserver_backend;
return (pass);
}
- /* Clamp the host header to 'parsoid' */
+ // Clamp the host header to 'parsoid'
set req.http.host = "parsoid";
- /* Support HTTP PURGE */
+ // Support HTTP PURGE
if (req.request == "PURGE") {
set req.hash_ignore_busy = true;
return (lookup);
@@ -19,14 +19,14 @@
set req.hash_always_miss = true;
}
- # Do not wait on concurrent (possibly actually fetching) requests
- # for only-if-cached. One would think this could be backend-only,
- # but it needs to happen in the frontend as well for the same
- # reason (frontend stalling an only-if-cached miss fetch from
- # the backend to coalesce with a non-only-if-cached miss fetch
- # from the backend)
+ // Do not wait on concurrent (possibly actually fetching) requests for
+ // only-if-cached. One would think this could be backend-only, but it
+ // needs to happen in the frontend as well for the same reason
+ // (frontend stalling an only-if-cached miss fetch from the backend to
+ // coalesce with a non-only-if-cached miss fetch from the backend)
if (req.http.Cache-Control ~ "only-if-cached") {
set req.hash_ignore_busy = true;
- return (lookup); // skip default vcl_recv which can generate
pass in some cases...
+ return (lookup); // skip default vcl_recv which can generate
+ // pass in some cases...
}
}
diff --git a/templates/varnish/parsoid-frontend.inc.vcl.erb
b/templates/varnish/parsoid-frontend.inc.vcl.erb
index 4c83dd2..e62fd78 100644
--- a/templates/varnish/parsoid-frontend.inc.vcl.erb
+++ b/templates/varnish/parsoid-frontend.inc.vcl.erb
@@ -1,6 +1,6 @@
-# Varnish VCL include file for Parsoid frontends
+// Varnish VCL include file for Parsoid frontends
-# Include common Parsoid config shared between front- and backend
+// Include common Parsoid config shared between front- and backend
include "parsoid-common.inc.vcl";
sub vcl_miss {
diff --git a/templates/varnish/text-backend.inc.vcl.erb
b/templates/varnish/text-backend.inc.vcl.erb
index da68497..2c291f7 100644
--- a/templates/varnish/text-backend.inc.vcl.erb
+++ b/templates/varnish/text-backend.inc.vcl.erb
@@ -1,10 +1,10 @@
-# Varnish VCL include file for text backends
+// Varnish VCL include file for text backends
include "errorpage.inc.vcl";
include "text-common.inc.vcl";
<% if @vcl_config.fetch("cluster_tier", "1") != "1" -%>
-# A random director with the same backends as the default 'backend' (chash)
director
+// A random director with the same backends as the default 'backend' (chash)
director
<%
default_backend = @vcl_config.fetch("default_backend", "backend")
-%>
@@ -60,8 +60,8 @@
}
sub vcl_fetch {
- /* Make sure Set-Cookie responses are not cacheable, and log violations
*/
- /* FIXME: exceptions are ugly; maybe get rid of the whole thing? */
+ // Make sure Set-Cookie responses are not cacheable, and log violations
+ // FIXME: exceptions are ugly; maybe get rid of the whole thing?
if (beresp.ttl > 0s && beresp.http.Set-Cookie &&
req.url !~ "^/wiki/Special:HideBanners") {
std.log("Cacheable object with Set-Cookie found. req.url: " +
req.url + " Cache-Control: " + beresp.http.Cache-Control + " Set-Cookie: " +
beresp.http.Set-Cookie);
@@ -70,7 +70,7 @@
return (hit_for_pass);
}
- /* FIXME: Fix up missing Vary headers on Apache redirects */
+ // FIXME: Fix up missing Vary headers on Apache redirects
if ((beresp.status == 301 || beresp.status == 302)
&& beresp.http.Location ~ "^http"
&& beresp.http.Vary !~ "X-Forwarded-Proto") {
diff --git a/templates/varnish/text-common.inc.vcl.erb
b/templates/varnish/text-common.inc.vcl.erb
index ac28d05..9f3f8b2 100644
--- a/templates/varnish/text-common.inc.vcl.erb
+++ b/templates/varnish/text-common.inc.vcl.erb
@@ -1,4 +1,4 @@
-# Common functions for the Text Varnish cluster
+// Common functions for the Text Varnish cluster
sub pass_requests {
if (req.request != "GET" && req.request != "HEAD") {
@@ -10,12 +10,12 @@
}
sub cookie_munging {
- /* This header is saved, and restored before sending it to MediaWiki */
+ // This header is saved, and restored before sending it to MediaWiki
if (req.restarts == 0) {
set req.http.Orig-Cookie = req.http.Cookie;
unset req.http.Cookie;
- /* We need to vary on the forceHTTPS cookie */
+ // We need to vary on the forceHTTPS cookie
if (req.http.Orig-Cookie ~ "forceHTTPS=(1|true)") {
set req.http.Cookie = "forceHTTPS=1";
}
@@ -23,9 +23,8 @@
}
sub restore_cookie {
- /* Restore the original Cookie header for upstream
- * Assumes client header Orig-Cookie has been filtered!
- */
+ // Restore the original Cookie header for upstream
+ // Assumes client header Orig-Cookie has been filtered!
if (bereq.http.Orig-Cookie) {
set bereq.http.Cookie = bereq.http.Orig-Cookie;
unset bereq.http.Orig-Cookie;
@@ -33,12 +32,11 @@
}
sub evaluate_cookie {
- /* A session or token cookie will prevent caching if varied on,
- * move the Cookie header out of the way otherwise
- */
- /* gettingStarted exclusion is to work around e.g.
enwikigettingStartedUserToken=
- * FIXME: the gettingStarted exception can be removed after 2014-08-01
- */
+ // A session or token cookie will prevent caching if varied on,
+ // move the Cookie header out of the way otherwise
+ //
+ // gettingStarted exclusion is to work around e.g.
enwikigettingStartedUserToken=
+ // FIXME: the gettingStarted exception can be removed after 2014-08-01
if (req.http.Cookie ~ "([sS]ession|(?<!gettingStartedUser)Token)=") {
set req.hash_ignore_busy = true;
} else {
diff --git a/templates/varnish/text-frontend.inc.vcl.erb
b/templates/varnish/text-frontend.inc.vcl.erb
index 090ba22..1b30445 100644
--- a/templates/varnish/text-frontend.inc.vcl.erb
+++ b/templates/varnish/text-frontend.inc.vcl.erb
@@ -1,4 +1,4 @@
-# Varnish VCL include file for text frontends
+// Varnish VCL include file for text frontends
include "errorpage.inc.vcl";
include "text-common.inc.vcl";
@@ -21,7 +21,7 @@
// mobile-frontend.inc.vcl.erb for (m|zero).wikipedia.org and its
// subdomains.
-# A random director with the same backends as the default 'backend' (chash)
director
+// A random director with the same backends as the default 'backend' (chash)
director
<%
default_backend = @vcl_config.fetch("default_backend", "backend")
-%>
@@ -45,9 +45,9 @@
&& req.http.Cookie !~
"(stopMobileRedirect=true|mf_useformat=desktop)"
&& req.url ~
"^/(wiki|(gan|ike|iu|kk|ku|shi|sr|tg|uz|zh)(-[a-z]+)?)[/\?]") {
- # Separate regexps for clarity, but multiple regsubs instead of
- # "if host ~"/regsub matches for efficiency. Be careful to not
- # write overlapping/chaining regexps.
+ // Separate regexps for clarity, but multiple regsubs instead of
+ // "if host ~"/regsub matches for efficiency. Be careful to not
+ // write overlapping/chaining regexps.
set req.http.MobileHost = req.http.Host;
set req.http.MobileHost = regsub(req.http.MobileHost,
"^(www\.)?(mediawiki|wikimediafoundation|wikisource)\.", "m.\2.");
set req.http.MobileHost = regsub(req.http.MobileHost,
"^(commons|incubator|legalteam|meta|office|outreach|pl|species|strategy|wikimania201[2-5])\.(wikimedia)\.",
"\1.m.\2.");
@@ -81,12 +81,11 @@
call filter_headers;
call filter_noise;
- /* Allow purging */
+ // Allow purging
call vcl_recv_purge;
- /* FIXME: we're seeing an issue with Range requests and gzip/gunzip.
- * Disable Range requests for now.
- */
+ // FIXME: we're seeing an issue with Range requests and gzip/gunzip.
+ // Disable Range requests for now.
unset req.http.Range;
call rewrite_proxy_urls;
@@ -99,8 +98,8 @@
set req.hash_ignore_busy = true;
}
- /* Users that just logged out, should not get a 304 for their
- * (locally cached) logged in pages. */
+ // Users that just logged out, should not get a 304 for their
+ // (locally cached) logged in pages.
if (req.http.If-Modified-Since && req.http.Cookie ~ "LoggedOut") {
unset req.http.If-Modified-Since;
}
@@ -128,12 +127,12 @@
}
sub vcl_error {
- /* Support mobile redirects */
+ // Support mobile redirects
if (obj.status == 666) {
set obj.http.Location = req.http.Location;
set obj.status = 302;
set obj.http.Connection = "keep-alive";
- set obj.http.Content-Length = "0"; # BZ #62245
+ set obj.http.Content-Length = "0"; // BZ #62245
return (deliver);
}
@@ -142,7 +141,7 @@
}
sub vcl_deliver {
- /* Override the Cache-Control header for wiki content pages */
+ // Override the Cache-Control header for wiki content pages
if (req.url ~ "(?i)^/w(iki)?/.*"
&& req.url !~ "^/wiki/Special\:Banner(Controller|ListLoader)"
&& req.url !~ "(?i)^/w/(extensions/.*|api\.php)"
@@ -150,17 +149,16 @@
set resp.http.Cache-Control = "private, s-maxage=0, max-age=0,
must-revalidate";
}
<% if @cluster_options.fetch("enable_geoiplookup", false) -%>
- /* Perform GeoIP look-up and send the result as a session cookie */
+ // Perform GeoIP look-up and send the result as a session cookie
if (req.http.Orig-Cookie !~ "(^|;\s*)GeoIP=[^;]"
&& req.http.Cookie !~ "(^|;\s*)GeoIP=[^;]") {
call geoip_cookie;
}
<% end -%>
- /* Assemble X-Analytics header
- Some of the headers used for X-Analytics are not varied on, so add
them after the backend processing
- Note that vcl_deliver in other files may also modify X-Analytics.
- */
+ // Assemble X-Analytics header
+ // Some of the headers used for X-Analytics are not varied on, so add
them after the backend processing
+ // Note that vcl_deliver in other files may also modify X-Analytics.
if (req.http.X-Forwarded-Proto) {
if (resp.http.X-Analytics) {
set resp.http.X-Analytics = resp.http.X-Analytics +
";https=1";
diff --git a/templates/varnish/upload-backend.inc.vcl.erb
b/templates/varnish/upload-backend.inc.vcl.erb
index 0f9c2ab..af6c0b7 100644
--- a/templates/varnish/upload-backend.inc.vcl.erb
+++ b/templates/varnish/upload-backend.inc.vcl.erb
@@ -1,4 +1,4 @@
-# Varnish VCL include file for upload backends
+// Varnish VCL include file for upload backends
include "errorpage.inc.vcl";
@@ -67,7 +67,7 @@
set bereq.http.host = regsub(req.url,
"^/([^-/]+)/([^/]+)/thumb/.+$", "\2.\1.<%=
Regexp.escape(@cluster_options.fetch('top_domain', 'org')) %>");
set bereq.http.X-Original-URI = req.url;
- # Exceptions
+ // Exceptions
set bereq.http.host = regsub(bereq.http.host,
"^(meta|commons|internal|grants)\.wikipedia\.org$", "\1.wikimedia.org");
set bereq.http.host = regsub(bereq.http.host,
"^mediawiki\..+$", "www.mediawiki.org");
set bereq.http.host = regsub(bereq.http.host,
"^sources\.wikipedia\.org$", "wikisource.org");
@@ -91,7 +91,7 @@
error 403 "Requested target domain not allowed.";
}
- /* Make sure high range requests don't block on large objects being
retrieved */
+ // Make sure high range requests don't block on large objects being
retrieved
if (req.http.Range
&& (std.integer(regsub(req.http.Range, "^bytes=([0-9]*)-",
"\1"), 0) > 33554432
|| req.http.Range ~ "^bytes=([0-9]{9,})-")) {
@@ -102,17 +102,17 @@
}
sub vcl_fetch {
- # Cache media objects for 30 days by default
+ // Cache media objects for 30 days by default
if (beresp.status <= 400) {
set beresp.ttl = 30d;
}
- # Stream large objects, >= 1 MB
+ // Stream large objects, >= 1 MB
if (std.integer(beresp.http.Content-Length, 0) >= 1048576 ||
beresp.http.Content-Length ~ "^[0-9]{9}") {
set beresp.do_stream = true;
}
- /* Select a random big object storage backend for objects >= 100 MB */
+ // Select a random big object storage backend for objects >= 100 MB
if (beresp.http.Content-Length ~ "^[0-9]{9}") {
call pick_large_object_stevedore;
} else {
@@ -120,13 +120,12 @@
}
if (beresp.http.Content-Range) {
- /* Varnish itself doesn't ask for ranges, so this must have been
- * a passed range request
- */
+ // Varnish itself doesn't ask for ranges, so this must have been
+ // a passed range request
set beresp.http.X-Content-Range = beresp.http.Content-Range;
}
- # Derive the corresponding original URL and store it with the object
+ // Derive the corresponding original URL and store it with the object
if (!beresp.http.X-MediaWiki-Original && req.url ~
"^/+[^/]+/[^/]+/thumb/[^/]+/[^/]+/[^/]+/[0-9]+px-") {
set beresp.http.X-MediaWiki-Original = regsub(req.url,
"^(/+[^/]+/[^/]+/)thumb/([^/]+/[^/]+/[^/]+).*$", "\1\2");
}
@@ -141,7 +140,7 @@
}
sub vcl_miss {
- /* Convert range requests into pass when over a certain threshold */
+ // Convert range requests into pass when over a certain threshold
if (req.http.Range
&& (std.integer(regsub(req.http.Range, "^bytes=([0-9]*)-",
"\1"), 0) > 33554432
|| req.http.Range ~ "^bytes=([0-9]{9,})-")) {
diff --git a/templates/varnish/upload-frontend.inc.vcl.erb
b/templates/varnish/upload-frontend.inc.vcl.erb
index d4cbf54..14d7abe 100644
--- a/templates/varnish/upload-frontend.inc.vcl.erb
+++ b/templates/varnish/upload-frontend.inc.vcl.erb
@@ -1,30 +1,30 @@
-# Varnish VCL include file for upload frontends
+// Varnish VCL include file for upload frontends
include "errorpage.inc.vcl";
sub vcl_recv {
call vcl_recv_purge;
- /* CORS preflight requests */
+ // CORS preflight requests
if (req.request == "OPTIONS" && req.http.Origin) {
error 667 "CORS";
}
if (req.request != "GET" && req.request != "HEAD") {
- /* We only deal with GET, HEAD at this point */
+ // We only deal with GET, HEAD at this point
error 403 "HTTP method not allowed";
}
- /* Look for a "download" request parameter */
+ // Look for a "download" request parameter
if (req.url ~ "(?i)(\?|&)download(=|&|$)") {
- /* Pretend that the parameter wasn't there for caching purposes
*/
+ // Pretend that the parameter wasn't there for caching purposes
set req.url = regsub(req.url, "(?i)(\?|&)download(=[^&]+)?$",
"");
set req.url = regsub(req.url, "(?i)(\?|&)download(=[^&]+)?&",
"\1");
set req.http.X-Content-Disposition = "attachment";
}
if (req.http.host == "<%= @cluster_options.fetch('upload_domain',
'upload.wikimedia.org') %>") {
- # Replace double slashes
+ // Replace double slashes
set req.url = regsuball(req.url, "/{2,}", "/");
return (lookup);
} else {
@@ -39,43 +39,42 @@
}
sub vcl_miss {
- /* Convert range requests into pass */
+ // Convert range requests into pass
if (req.http.Range) {
set bereq.http.Range = req.http.Range;
return (pass);
}
- /* Make sure If-Cached requests won't pollute the cache */
+ // Make sure If-Cached requests won't pollute the cache
if (req.http.If-Cached) {
return (pass);
}
}
sub vcl_fetch {
- # Cap media object cache TTLs to 1 hour
+ // Cap media object cache TTLs to 1 hour
if (beresp.ttl > 1h) {
set beresp.ttl = 1h;
}
if (beresp.http.Content-Range) {
- /* Varnish itself doesn't ask for ranges, so this must have been
- * a passed range request
- */
+ // Varnish itself doesn't ask for ranges, so this must have been
+ // a passed range request
set beresp.http.X-Content-Range = beresp.http.Content-Range;
if (beresp.http.Content-Range ~ "\/[0-9]{8,}$") {
set beresp.do_stream = true;
- /* don't attempt to cache these in the frontend */
+ // don't attempt to cache these in the frontend
return (hit_for_pass);
}
}
- # Stream large objects, >= 1 or 32 MB
+ // Stream large objects, >= 1 or 32 MB
<% stream_threshold = @vcl_config.fetch("cluster_tier", "1") == "1" ? 33554432
: 1048576 -%>
if (std.integer(beresp.http.Content-Length, 33554432) >= <%=
stream_threshold %> || beresp.http.Content-Length ~ "^[0-9]{9}") {
set beresp.do_stream = true;
if (std.integer(beresp.http.Content-Length, 33554432) >=
33554432 || beresp.http.Content-Length ~ "^[0-9]{9}") {
- /* don't attempt to cache these in the frontend */
+ // don't attempt to cache these in the frontend
return (hit_for_pass);
}
}
@@ -84,14 +83,14 @@
}
sub vcl_error {
- /* Handle CORS preflight requests */
+ // Handle CORS preflight requests
if (obj.status == 667) {
set obj.status = 200;
set obj.response = "OK";
set obj.http.Connection = "keep-alive";
set obj.http.Content-Length = "0";
- /* allow Range requests, used by ogv.js */
+ // allow Range requests, used by ogv.js
set obj.http.Access-Control-Allow-Origin = "*";
set obj.http.Access-Control-Allow-Headers = "Range";
set obj.http.Access-Control-Allow-Methods = "GET, HEAD,
OPTIONS";
diff --git a/templates/varnish/zero.inc.vcl.erb
b/templates/varnish/zero.inc.vcl.erb
index 9d949d9..2e005ab 100644
--- a/templates/varnish/zero.inc.vcl.erb
+++ b/templates/varnish/zero.inc.vcl.erb
@@ -1,6 +1,6 @@
-# Varnish VCL include file for Wikipedia Zero
+// Varnish VCL include file for Wikipedia Zero
-# Note: This requires "import header" in the including VCL
+// Note: This requires "import header" in the including VCL
import netmapper;
@@ -17,13 +17,13 @@
// (the leading "..." in XFF is that sometimes there are other local
// proxies on 127.0.0.1 or whatever, according to some OperaMini docs...)
- /*********************************************************
- * v> | client.ip | XFF | XFP
- * direct| client | (...,)? client |
- * ssl | ssl | (...,)? client, ssl | https
- * proxy | proxy | (...,)? client, proxy |
- * both | ssl | (...,)? client, proxy, ssl | https
- *********************************************************/
+ // *********************************************************
+ // * v> | client.ip | XFF | XFP
+ // * direct| client | (...,)? client |
+ // * ssl | ssl | (...,)? client, ssl | https
+ // * proxy | proxy | (...,)? client, proxy |
+ // * both | ssl | (...,)? client, proxy, ssl | https
+ // *********************************************************
// first, strip the SSL entry from XFF if applicable
if (req.http.X-Forwarded-Proto) {
@@ -32,11 +32,11 @@
set req.http.XFF-NoSSL = req.http.X-Forwarded-For;
}
-
/*****************************************************************************
- * v> | XFF-NoSSL | map("proxies") input from regsub
below
- * direct/ssl | (...,)? client | client
- * proxy/both | (...,)? client, proxy | proxy
-
*****************************************************************************/
+ //
*****************************************************************************
+ // * v> | XFF-NoSSL | map("proxies") input from regsub
below
+ // * direct/ssl | (...,)? client | client
+ // * proxy/both | (...,)? client, proxy | proxy
+ //
*****************************************************************************
// now get the trusted proxy into XFB, if any - the regsub grabs the final
entry in the list
set req.http.X-Forwarded-By = netmapper.map("proxies",
regsub(req.http.XFF-NoSSL, "^([^,]+, ?)+", ""));
@@ -55,10 +55,10 @@
unset req.http.XFF-NoSSL; // clean up temp var
- /****************************************************************
- * v> | XFF-CE | map("carriers") input from regsub below
- * all | (...,)? client | client
- *****************************************************************/
+ // ****************************************************************
+ // * v> | XFF-CE | map("carriers") input from regsub below
+ // * all | (...,)? client | client
+ // *****************************************************************
// Grab client IP from the end of the XFF-CE list and feed to map("zero")
set req.http.X-CS2 = netmapper.map("carriers",
regsub(req.http.XFF-ClientEnd, "^([^,]+, ?)+", ""));
--
To view, visit https://gerrit.wikimedia.org/r/184570
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I12f4495dbad33c4b30611df27830d1033f6d441a
Gerrit-PatchSet: 4
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Ori.livneh <[email protected]>
Gerrit-Reviewer: BBlack <[email protected]>
Gerrit-Reviewer: Faidon Liambotis <[email protected]>
Gerrit-Reviewer: Ori.livneh <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits