From 3057f901bc36eafb1e3a355716f2c8b96399e6d2 Mon Sep 17 00:00:00 2001 From: Clayton Han-Mitchell Date: Fri, 3 Apr 2015 10:39:30 -0700 Subject: [PATCH] Getting feet wet, added origin host header for sites which require it match the site name --- .../src/main/groovy/filters/pre/PreDecoration.groovy | 3 +++ .../src/main/groovy/filters/route/SimpleHostRequest.groovy | 1 + 2 files changed, 4 insertions(+) diff --git a/zuul-simple-webapp/src/main/groovy/filters/pre/PreDecoration.groovy b/zuul-simple-webapp/src/main/groovy/filters/pre/PreDecoration.groovy index 0ef694bde3..e65d2c9340 100644 --- a/zuul-simple-webapp/src/main/groovy/filters/pre/PreDecoration.groovy +++ b/zuul-simple-webapp/src/main/groovy/filters/pre/PreDecoration.groovy @@ -44,6 +44,9 @@ class PreDecorationFilter extends ZuulFilter { // sets origin ctx.setRouteHost(new URL("http://apache.org/")); + // set origin host header + ctx.addZuulRequestHeader("Host","apache.org"); + // sets custom header to send to the origin ctx.addOriginResponseHeader("cache-control", "max-age=3600"); } diff --git a/zuul-simple-webapp/src/main/groovy/filters/route/SimpleHostRequest.groovy b/zuul-simple-webapp/src/main/groovy/filters/route/SimpleHostRequest.groovy index 7bb8fa9b6b..5c180880c1 100644 --- a/zuul-simple-webapp/src/main/groovy/filters/route/SimpleHostRequest.groovy +++ b/zuul-simple-webapp/src/main/groovy/filters/route/SimpleHostRequest.groovy @@ -278,6 +278,7 @@ class SimpleHostRoutingFilter extends ZuulFilter { boolean isValidHeader(String name) { if (name.toLowerCase().contains("content-length")) return false; + if (name.toLowerCase().equals("host")) return false; // set host according to origin vhost if (!RequestContext.currentContext.responseGZipped) { if (name.toLowerCase().contains("accept-encoding")) return false; }