Mark Bergsma has uploaded a new change for review.

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


Change subject: Factor out XFF append handling into a common function
......................................................................

Factor out XFF append handling into a common function

Change-Id: I42587b856dfc533bd25358d9bd514d4a1119582a
---
M modules/varnish/templates/vcl/wikimedia.vcl.erb
M templates/varnish/mobile-backend.inc.vcl.erb
M templates/varnish/mobile-frontend.inc.vcl.erb
3 files changed, 12 insertions(+), 16 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/17/75317/1

diff --git a/modules/varnish/templates/vcl/wikimedia.vcl.erb 
b/modules/varnish/templates/vcl/wikimedia.vcl.erb
index 4acf461..9d4319b 100644
--- a/modules/varnish/templates/vcl/wikimedia.vcl.erb
+++ b/modules/varnish/templates/vcl/wikimedia.vcl.erb
@@ -189,6 +189,16 @@
        }
 }
 
+sub vcl_recv_append_xff {
+       if (req.restarts == 0) {
+               if (req.http.X-Forwarded-For) {
+                       set req.http.X-Forwarded-For = req.http.X-Forwarded-For 
+ ", " + client.ip;
+               } else {
+                       set req.http.X-Forwarded-For = client.ip;
+               }
+       }
+}
+
 <% if ! wikimedia_networks.empty? -%>
 sub restrict_access {
        if (client.ip !~ wikimedia_nets) {
diff --git a/templates/varnish/mobile-backend.inc.vcl.erb 
b/templates/varnish/mobile-backend.inc.vcl.erb
index 70992b0..3f9c9b7 100644
--- a/templates/varnish/mobile-backend.inc.vcl.erb
+++ b/templates/varnish/mobile-backend.inc.vcl.erb
@@ -19,14 +19,7 @@
 <% end -%>
 
        /* Default (now modified) Varnish vcl_recv function */
-       if (req.restarts == 0) {
-               if (req.http.x-forwarded-for) {
-                       set req.http.X-Forwarded-For =
-                       req.http.X-Forwarded-For + ", " + client.ip;
-               } else {
-                       set req.http.X-Forwarded-For = client.ip;
-               }
-       }
+       call vcl_recv_append_xff;
        if (req.request != "GET" && req.request != "HEAD") {
                /* We only deal with GET and HEAD by default */
                return (pass);
diff --git a/templates/varnish/mobile-frontend.inc.vcl.erb 
b/templates/varnish/mobile-frontend.inc.vcl.erb
index d43d215..d418201 100644
--- a/templates/varnish/mobile-frontend.inc.vcl.erb
+++ b/templates/varnish/mobile-frontend.inc.vcl.erb
@@ -88,14 +88,7 @@
        set req.hash_ignore_busy = true;
 
        /* Default (now modified) Varnish vcl_recv function */
-       if (req.restarts == 0) {
-               if (req.http.x-forwarded-for) {
-                       set req.http.X-Forwarded-For =
-                       req.http.X-Forwarded-For + ", " + client.ip;
-               } else {
-                       set req.http.X-Forwarded-For = client.ip;
-               }
-       }
+       call vcl_recv_append_xff;
        if (req.request != "GET" && req.request != "HEAD") {
                /* We only deal with GET and HEAD by default */
                return (pass);

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I42587b856dfc533bd25358d9bd514d4a1119582a
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Mark Bergsma <m...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to