Faidon Liambotis has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/170883

Change subject: varnish: allow POST for EventLogging on bits
......................................................................

varnish: allow POST for EventLogging on bits

The sendBeacon W3C API works by issuing POSTs to EventLogging URLs.
Currently, we issue a "method not allowed" on POSTs; while that would
still work with EventLogging (as neither the browser nor EL would care
about the status code), this would elevate our error statistics. Handle
this case by moving the conditional block and thus allowing POSTs
specifically for event.gif.

Change-Id: I7d752d1fe84620ed64101d6bece7631057a8a3e6
RT: 8612
---
M templates/varnish/bits.inc.vcl.erb
1 file changed, 7 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/83/170883/1

diff --git a/templates/varnish/bits.inc.vcl.erb 
b/templates/varnish/bits.inc.vcl.erb
index 769f5e4..c0c0a46 100644
--- a/templates/varnish/bits.inc.vcl.erb
+++ b/templates/varnish/bits.inc.vcl.erb
@@ -23,11 +23,6 @@
 <% end -%>
 
 sub vcl_recv {
-       /* Since we are allowing POST at wikimedia3.vcl.erb, disallow here */
-       if (req.request == "POST") {
-               error 403 "HTTP method not allowed.";
-       }
-
        /* transform the cookie in an http header */
        if (req.http.Cookie ~ "hhvm=true") {
                set req.http.X-Use-HHVM = 1;
@@ -44,12 +39,18 @@
                if (req.url ~ "^/event\.gif") {
                        error 204;
                }
-       /* For https-only wikis, the redirect from http to https for bits 
assets should occur
+
+               if (req.request == "POST") {
+                       error 403 "HTTP method not allowed";
+               }
+
+               /* 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;
                }
+
 <% if cluster_options.fetch( "enable_geoiplookup", false ) -%>
                if (req.url == "/geoiplookup") {
                        error 666 "geoiplookup";

-- 
To view, visit https://gerrit.wikimedia.org/r/170883
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7d752d1fe84620ed64101d6bece7631057a8a3e6
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Faidon Liambotis <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to