Ori.livneh has uploaded a new change for review.
https://gerrit.wikimedia.org/r/184570
Change subject: VCL: Standardize on '//'-style comments
......................................................................
VCL: Standardize on '//'-style comments
Change-Id: I12f4495dbad33c4b30611df27830d1033f6d441a
---
M templates/varnish/bits.inc.vcl.erb
M templates/varnish/blog.inc.vcl.erb
M templates/varnish/geoip.inc.vcl.erb
M templates/varnish/graphite.inc.vcl.erb
M templates/varnish/hhvm.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
17 files changed, 164 insertions(+), 178 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/operations/puppet
refs/changes/70/184570/1
diff --git a/templates/varnish/bits.inc.vcl.erb
b/templates/varnish/bits.inc.vcl.erb
index f6424fc..ed7ceb1 100644
--- a/templates/varnish/bits.inc.vcl.erb
+++ b/templates/varnish/bits.inc.vcl.erb
@@ -1,19 +1,18 @@
-# Varnish VCL include file for bits
+// Varnish VCL include file for bits
include "errorpage.inc.vcl";
include "hhvm.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;
}
@@ -40,9 +39,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;
}
@@ -68,16 +67,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);
}
@@ -88,11 +85,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;
}
@@ -100,7 +95,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;
@@ -108,12 +103,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/blog.inc.vcl.erb
b/templates/varnish/blog.inc.vcl.erb
index d62db52..a4b2ff2 100644
--- a/templates/varnish/blog.inc.vcl.erb
+++ b/templates/varnish/blog.inc.vcl.erb
@@ -1,13 +1,13 @@
-# Varnish VCL include file for blog
-#
-# This is a terrible hack - W3 cache on our wordpress install is sending
-# varnish purge requests as:
-# GET /uri/to/purge HTTP/1.1
-# Host: 127.0.0.1
-#
-# this seems to be a problem with the http dispatcher being used
-# (aka curl, etc.)
-#
+// Varnish VCL include file for blog
+//
+// This is a terrible hack - W3 cache on our wordpress install is sending
+// varnish purge requests as:
+// GET /uri/to/purge HTTP/1.1
+// Host: 127.0.0.1
+//
+// this seems to be a problem with the http dispatcher being used
+// (aka curl, etc.)
+
sub vcl_recv {
call device_detection;
call vcl_recv_purge;
@@ -24,10 +24,10 @@
}
sub vcl_fetch {
- set beresp.http.X-Mobile = req.http.X-Mobile; # for debugging
- if (!beresp.http.Vary) { # no Vary at all
+ set beresp.http.X-Mobile = req.http.X-Mobile; // for debugging
+ if (!beresp.http.Vary) { // no Vary at all
set beresp.http.Vary = "X-Mobile";
- } elseif (beresp.http.Vary !~ "X-Mobile") { # add to existing Vary
+ } elseif (beresp.http.Vary !~ "X-Mobile") { // add to existing Vary
set beresp.http.Vary = beresp.http.Vary + ", X-Mobile";
}
}
diff --git a/templates/varnish/geoip.inc.vcl.erb
b/templates/varnish/geoip.inc.vcl.erb
index 083287c..9eaa863 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/graphite.inc.vcl.erb
b/templates/varnish/graphite.inc.vcl.erb
index 2c1edf0..b197f87 100644
--- a/templates/varnish/graphite.inc.vcl.erb
+++ b/templates/varnish/graphite.inc.vcl.erb
@@ -1,6 +1,6 @@
-# Varnish VCL include file for gdash
+// Varnish VCL include file for gdash
#
-# Just some short lived caching for /render and a bit more for everything else
+// Just some short lived caching for /render and a bit more for everything else
#
sub vcl_fetch {
diff --git a/templates/varnish/hhvm.inc.vcl.erb
b/templates/varnish/hhvm.inc.vcl.erb
index 1712b5f..ed84b05 100644
--- a/templates/varnish/hhvm.inc.vcl.erb
+++ b/templates/varnish/hhvm.inc.vcl.erb
@@ -1,6 +1,6 @@
-# Common functions for HHVM handling
+// Common functions for HHVM handling
-/* Manage X-Analytics token for HHVM/Zend tracking */
+// Manage X-Analytics token for HHVM/Zend tracking
sub php_mark_engine {
if (resp.http.X-Analytics) {
if (resp.http.X-Powered-By ~ "^HHVM") {
diff --git a/templates/varnish/misc.inc.vcl.erb
b/templates/varnish/misc.inc.vcl.erb
index cdafd99..0ef8e48 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 a62f432..3265a6d 100644
--- a/templates/varnish/mobile-backend.inc.vcl.erb
+++ b/templates/varnish/mobile-backend.inc.vcl.erb
@@ -1,11 +1,11 @@
-# Varnish VCL include file for mobile backends
+// Varnish VCL include file for mobile backends
include "errorpage.inc.vcl";
include "hhvm.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" -%>
@@ -19,13 +19,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 ba48614..e4c83b9 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";
@@ -24,7 +24,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";
}
@@ -37,9 +37,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
@@ -56,7 +55,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") {
@@ -65,33 +64,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;
}
@@ -109,13 +107,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);
@@ -142,7 +140,7 @@
}
sub vcl_error {
- /* Support mobile redirects */
+ // Support mobile redirects
if (obj.status == 666) {
set obj.http.Location = obj.response;
set obj.status = 302;
@@ -157,10 +155,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";
@@ -183,15 +180,15 @@
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";
}
call php_mark_engine;
- /* 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 8e7973e..a0726da 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;
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,12 +19,12 @@
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...
diff --git a/templates/varnish/parsoid-frontend.inc.vcl.erb
b/templates/varnish/parsoid-frontend.inc.vcl.erb
index 1be9da4..8a526fe 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 5d0e8f4..8c21c83 100644
--- a/templates/varnish/text-backend.inc.vcl.erb
+++ b/templates/varnish/text-backend.inc.vcl.erb
@@ -1,11 +1,11 @@
-# Varnish VCL include file for text backends
+// Varnish VCL include file for text backends
include "errorpage.inc.vcl";
include "text-common.inc.vcl";
include "hhvm.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")
-%>
@@ -61,8 +61,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);
@@ -71,7 +71,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 b63d51c..8a6aa21 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";
@@ -23,7 +23,7 @@
include "hhvm.inc.vcl";
-# 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")
-%>
@@ -47,9 +47,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.");
@@ -83,12 +83,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;
@@ -101,8 +100,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;
}
@@ -130,12 +129,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);
}
@@ -144,7 +143,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)"
@@ -153,17 +152,16 @@
}
call php_mark_engine;
<% 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 ce1b538..a56b7e9 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 8cb1a95..3cad284 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: newchange
Gerrit-Change-Id: I12f4495dbad33c4b30611df27830d1033f6d441a
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Ori.livneh <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits