diff --git a/1.0.x/index.html b/1.0.x/index.html index 55d35ba0..69c52cdd 100644 --- a/1.0.x/index.html +++ b/1.0.x/index.html @@ -32,7 +32,7 @@ color: #ffffff; } - + + + + Click here if you are not redirected. + diff --git a/js/backbone.js b/js/backbone.js index 3512d42f..7197d646 100644 --- a/js/backbone.js +++ b/js/backbone.js @@ -3,7 +3,7 @@ // (c) 2010-2013 Jeremy Ashkenas, DocumentCloud Inc. // Backbone may be freely distributed under the MIT license. // For all details and documentation: -// http://backbonejs.org +// https://backbonejs.org (function(){ @@ -1298,7 +1298,7 @@ // ---------------- // Handles cross-browser history management, based on either - // [pushState](http://diveintohtml5.info/history.html) and real URLs, or + // [pushState](https://diveintohtml5.info/history.html) and real URLs, or // [onhashchange](https://developer.mozilla.org/en-US/docs/DOM/window.onhashchange) // and URL fragments. If the browser supports neither (old IE, natch), // falls back to polling. diff --git a/js/highlight/styles/dracula.min.css b/js/highlight/styles/dracula.min.css index d591db68..578f0b40 100644 --- a/js/highlight/styles/dracula.min.css +++ b/js/highlight/styles/dracula.min.css @@ -7,7 +7,7 @@ https://github.com/zenorocha/dracula-theme Copyright 2015, All rights reserved Code licensed under the MIT license -http://zenorocha.mit-license.org +https://zenorocha.mit-license.org/ @author Éverton Ribeiro @author Zeno Rocha diff --git a/js/highlight/styles/monokai-sublime.min.css b/js/highlight/styles/monokai-sublime.min.css index 2864170d..ed52c92e 100644 --- a/js/highlight/styles/monokai-sublime.min.css +++ b/js/highlight/styles/monokai-sublime.min.css @@ -1,6 +1,6 @@ /* -Monokai Sublime style. Derived from Monokai by noformnocontent http://nn.mit-license.org/ +Monokai Sublime style. Derived from Monokai by noformnocontent https://nn.mit-license.org/ */ diff --git a/js/highlight/styles/monokai.min.css b/js/highlight/styles/monokai.min.css index 775d53f9..a5735585 100644 --- a/js/highlight/styles/monokai.min.css +++ b/js/highlight/styles/monokai.min.css @@ -1,5 +1,5 @@ /* -Monokai style - ported by Luigi Maselli - http://grigio.org +Monokai style - ported by Luigi Maselli - https://grigio.org */ .hljs { diff --git a/js/jquery.js b/js/jquery.js index 6f8c9675..89181508 100644 --- a/js/jquery.js +++ b/js/jquery.js @@ -1,13 +1,13 @@ /*! * jQuery JavaScript Library v1.10.1 - * http://jquery.com/ + * https://jquery.com/ * * Includes Sizzle.js - * http://sizzlejs.com/ + * https://sizzlejs.com/ * * Copyright 2005, 2013 jQuery Foundation, Inc. and other contributors * Released under the MIT license - * http://jquery.org/license + * https://jquery.org/license * * Date: 2013-05-30T21:49Z */ @@ -561,7 +561,7 @@ jQuery.extend({ if ( data ) { // Make sure the incoming data is actual JSON - // Logic borrowed from http://json.org/json2.js + // Logic borrowed from https://json.org/json2.js if ( rvalidchars.test( data.replace( rvalidescape, "@" ) .replace( rvalidtokens, "]" ) .replace( rvalidbraces, "")) ) { @@ -602,7 +602,7 @@ jQuery.extend({ // Evaluates a script in a global context // Workarounds based on findings by Jim Driscoll - // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context + // https://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context globalEval: function( data ) { if ( data && jQuery.trim( data ) ) { // We use execScript on Internet Explorer @@ -921,7 +921,7 @@ jQuery.ready.promise = function( obj ) { // Catch cases where $(document).ready() is called after the browser event has already occurred. // we once tried to use readyState "interactive" here, but it caused issues like the one - // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15 + // discovered by ChrisS here: https://bugs.jquery.com/ticket/12282#comment:15 if ( document.readyState === "complete" ) { // Handle it asynchronously to allow scripts the opportunity to delay ready setTimeout( jQuery.ready ); @@ -1001,11 +1001,11 @@ function isArraylike( obj ) { rootjQuery = jQuery(document); /*! * Sizzle CSS Selector Engine v1.9.4-pre - * http://sizzlejs.com/ + * https://sizzlejs.com/ * * Copyright 2013 jQuery Foundation, Inc. and other contributors * Released under the MIT license - * http://jquery.org/license + * https://jquery.org/license * * Date: 2013-05-27 */ @@ -1069,17 +1069,17 @@ var i, // Regular expressions - // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace + // Whitespace characters https://www.w3.org/TR/css3-selectors/#whitespace whitespace = "[\\x20\\t\\r\\n\\f]", - // http://www.w3.org/TR/css3-syntax/#characters + // https://www.w3.org/TR/css3-syntax/#characters characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+", // Loosely modeled on CSS identifier characters - // An unquoted value should be a CSS identifier http://www.w3.org/TR/css3-selectors/#attribute-selectors - // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier + // An unquoted value should be a CSS identifier https://www.w3.org/TR/css3-selectors/#attribute-selectors + // Proper syntax: https://www.w3.org/TR/CSS21/syndata.html#value-def-identifier identifier = characterEncoding.replace( "w", "w#" ), - // Acceptable operators http://www.w3.org/TR/selectors/#attribute-selectors + // Acceptable operators https://www.w3.org/TR/selectors/#attribute-selectors attributes = "\\[" + whitespace + "*(" + characterEncoding + ")" + whitespace + "*(?:([*^$|!~]?=)" + whitespace + "*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|(" + identifier + ")|)|)" + whitespace + "*\\]", @@ -1129,7 +1129,7 @@ var i, rescape = /'|\\/g, - // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters + // CSS escapes https://www.w3.org/TR/CSS21/syndata.html#escaped-characters runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ), funescape = function( _, escaped, escapedWhitespace ) { var high = "0x" + escaped - 0x10000; @@ -1376,7 +1376,7 @@ function boolHandler( elem, name ) { /** * Fetches attributes without interpolation - * http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx + * https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx * @param {Element} elem * @param {String} name */ @@ -1653,7 +1653,7 @@ setDocument = Sizzle.setDocument = function( node ) { // We allow this because of a bug in IE8/9 that throws an error // whenever `document.activeElement` is accessed on an iframe // So, we allow :focus to pass through QSA all the time to avoid the IE error - // See http://bugs.jquery.com/ticket/13378 + // See https://bugs.jquery.com/ticket/13378 rbuggyQSA = []; if ( (support.qsa = isNative(doc.querySelectorAll)) ) { @@ -1664,7 +1664,7 @@ setDocument = Sizzle.setDocument = function( node ) { // This is to test IE's treatment of not explicitly // setting a boolean content attribute, // since its presence should be enough - // http://bugs.jquery.com/ticket/12359 + // https://bugs.jquery.com/ticket/12359 div.innerHTML = ""; // Support: IE8 @@ -1674,7 +1674,7 @@ setDocument = Sizzle.setDocument = function( node ) { } // Webkit/Opera - :checked should return selected option elements - // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked + // https://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked // IE8 throws error here and will not see later tests if ( !div.querySelectorAll(":checked").length ) { rbuggyQSA.push(":checked"); @@ -2219,7 +2219,7 @@ Expr = Sizzle.selectors = { "PSEUDO": function( pseudo, argument ) { // pseudo-class names are case-insensitive - // http://www.w3.org/TR/selectors/#pseudo-classes + // https://www.w3.org/TR/selectors/#pseudo-classes // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters // Remember that setFilters inherits from pseudos var args, @@ -2303,7 +2303,7 @@ Expr = Sizzle.selectors = { // or beginning with the identifier C immediately followed by "-". // The matching of C against the element's language value is performed case-insensitively. // The identifier C does not have to be a valid language name." - // http://www.w3.org/TR/selectors/#lang-pseudo + // https://www.w3.org/TR/selectors/#lang-pseudo "lang": markFunction( function( lang ) { // lang value must be a valid identifier if ( !ridentifier.test(lang || "") ) { @@ -2350,7 +2350,7 @@ Expr = Sizzle.selectors = { "checked": function( elem ) { // In CSS3, :checked should return both checked and selected elements - // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked + // https://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked var nodeName = elem.nodeName.toLowerCase(); return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected); }, @@ -2367,7 +2367,7 @@ Expr = Sizzle.selectors = { // Contents "empty": function( elem ) { - // http://www.w3.org/TR/selectors/#empty-pseudo + // https://www.w3.org/TR/selectors/#empty-pseudo // :empty is only affected by element nodes and content nodes(including text(3), cdata(4)), // not comment, processing instructions, or others // Thanks to Diego Perini for the nodeName shortcut @@ -4024,7 +4024,7 @@ jQuery.fn.extend({ }); }, // Based off of the plugin by Clint Helfers, with permission. - // http://blindsignals.com/index.php/2009/07/jquery-delay/ + // http://blindsignals.com delay: function( time, type ) { time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time; type = type || "fx"; @@ -4501,7 +4501,7 @@ jQuery.extend({ tabIndex: { get: function( elem ) { // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set - // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ + // https://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ // Use proper attribute retrieval(#12072) var tabindex = jQuery.find.attr( elem, "tabindex" ); @@ -4641,7 +4641,7 @@ if ( !getSetAttribute ) { // Some attributes require a special call on IE -// http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx +// https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx if ( !jQuery.support.hrefNormalized ) { // href/src property should get the full normalized URL (#10299/#12915) jQuery.each([ "href", "src" ], function( i, name ) { @@ -5413,7 +5413,7 @@ jQuery.Event = function( src, props ) { }; // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding -// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html +// https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html jQuery.Event.prototype = { isDefaultPrevented: returnFalse, isPropagationStopped: returnFalse, @@ -6516,7 +6516,7 @@ jQuery.extend({ if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) && (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) { - // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2 + // We eschew Sizzle here for performance reasons: https://jsperf.com/getall-vs-sizzle/2 destElements = getAll( clone ); srcElements = getAll( elem ); @@ -7120,7 +7120,7 @@ if ( window.getComputedStyle ) { // A tribute to the "awesome hack by Dean Edwards" // Chrome < 17 and Safari 5.0 uses "computed value" instead of "used value" for margin-right // Safari 5.1.7 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels - // this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values + // this is against the CSSOM draft spec: https://dev.w3.org/csswg/cssom/#resolved-values if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) { // Remember the original values @@ -8729,7 +8729,7 @@ if ( xhrSupported ) { // Firefox throws exceptions when accessing properties // of an xhr when a network error occurred - // http://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_(NS_ERROR_NOT_AVAILABLE) + // https://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_(NS_ERROR_NOT_AVAILABLE) try { // Was never called and is aborted or complete diff --git a/js/test/SpecRunner.html b/js/test/SpecRunner.html index 877cfa2b..66bdd3b6 100644 --- a/js/test/SpecRunner.html +++ b/js/test/SpecRunner.html @@ -4,7 +4,7 @@ title: Your Project Name Here --- + "https://www.w3.org/TR/html4/loose.dtd"> Jasmine Spec Runner diff --git a/js/test/lib/support/mock-ajax.js b/js/test/lib/support/mock-ajax.js index 5c99627a..bf17886f 100644 --- a/js/test/lib/support/mock-ajax.js +++ b/js/test/lib/support/mock-ajax.js @@ -4,9 +4,9 @@ Supports both Prototype.js and jQuery. - http://github.com/pivotal/jasmine-ajax + https://github.com/pivotal/jasmine-ajax - Jasmine Home page: http://pivotal.github.com/jasmine + Jasmine Home page: https://pivotal.github.com/jasmine Copyright (c) 2008-2010 Pivotal Labs diff --git a/js/test/spec/QuickStartWidgetSpec.js b/js/test/spec/QuickStartWidgetSpec.js index b5587776..3bafa1d0 100644 --- a/js/test/spec/QuickStartWidgetSpec.js +++ b/js/test/spec/QuickStartWidgetSpec.js @@ -6,18 +6,18 @@ describe("QuickStartWidget", function () { var project = new Spring.Project({ "id": "spring-data-jpa", "name": "Spring Data JPA", - "repoUrl": "http://github.com/SpringSource/spring-data-jpa", - "siteUrl": "http://projects.spring.io/spring-data-jpa", + "repoUrl": "https://github.com/SpringSource/spring-data-jpa", + "siteUrl": "https://projects.spring.io/spring-data-jpa", "projectReleases": [ { - "refDocUrl": "http://docs.spring.io/spring-data/jpa/docs/1.4.0.RC1/reference/html/", - "apiDocUrl": "http://docs.spring.io/spring-data/jpa/docs/1.4.0.RC1/api/", + "refDocUrl": "https://docs.spring.io/spring-data/jpa/docs/1.4.0.RC1/reference/html/", + "apiDocUrl": "https://docs.spring.io/spring-data/jpa/docs/1.4.0.RC1/api/", "groupId": "org.springframework.data", "artifactId": "spring-data-jpa", "repository": { "id": "spring-milestones", "name": "Spring Milestones", - "url": "http://repo.spring.io/milestone", + "url": "https://repo.spring.io/milestone", "snapshotsEnabled": false }, "version": "1.4.0.RC1", @@ -28,8 +28,8 @@ describe("QuickStartWidget", function () { "versionDisplayName": "1.4.0.RC1" }, { - "refDocUrl": "http://docs.spring.io/spring-data/jpa/docs/1.3.4.RELEASE/reference/html/", - "apiDocUrl": "http://docs.spring.io/spring-data/jpa/docs/1.3.4.RELEASE/api/", + "refDocUrl": "https://docs.spring.io/spring-data/jpa/docs/1.3.4.RELEASE/reference/html/", + "apiDocUrl": "https://docs.spring.io/spring-data/jpa/docs/1.3.4.RELEASE/api/", "groupId": "org.springframework.data", "artifactId": "spring-data-jpa", "repository": null, @@ -73,7 +73,7 @@ describe("QuickStartWidget", function () { expect($('#maven_widget')).toContainText("spring-milestones"); expect($('#maven_widget')).toContainText("Spring Milestones"); - expect($('#maven_widget')).toContainText("http://repo.spring.io/milestone"); + expect($('#maven_widget')).toContainText("https://repo.spring.io/milestone"); expect($('#maven_widget')).toContainText("false"); }); @@ -83,7 +83,7 @@ describe("QuickStartWidget", function () { expect($('#maven_widget')).not.toContainText("repository"); expect($('#maven_widget')).not.toContainText("spring-milestones"); expect($('#maven_widget')).not.toContainText("Spring Milestones"); - expect($('#maven_widget')).not.toContainText("http://repo.spring.io/milestone"); + expect($('#maven_widget')).not.toContainText("https://repo.spring.io/milestone"); expect($('#maven_widget')).not.toContainText("false"); }); }); @@ -102,7 +102,7 @@ describe("QuickStartWidget", function () { $('#jasmine_content select').val(0).change(); expect($('#maven_widget')).toContainText("repositories"); - expect($('#maven_widget')).toContainText("http://repo.spring.io/milestone"); + expect($('#maven_widget')).toContainText("https://repo.spring.io/milestone"); }); }); }); diff --git a/js/underscore.js b/js/underscore.js index 7d4ee27c..f5df8e03 100644 --- a/js/underscore.js +++ b/js/underscore.js @@ -1,5 +1,5 @@ // Underscore.js 1.5.1 -// http://underscorejs.org +// https://underscorejs.org // (c) 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors // Underscore may be freely distributed under the MIT license. @@ -554,7 +554,7 @@ // Generate an integer Array containing an arithmetic progression. A port of // the native Python `range()` function. See - // [the Python documentation](http://docs.python.org/library/functions.html#range). + // [the Python documentation](https://docs.python.org/library/functions.html#range). _.range = function(start, stop, step) { if (arguments.length <= 1) { stop = start || 0; @@ -844,7 +844,7 @@ // Internal recursive comparison function for `isEqual`. var eq = function(a, b, aStack, bStack) { // Identical objects are equal. `0 === -0`, but they aren't identical. - // See the [Harmony `egal` proposal](http://wiki.ecmascript.org/doku.php?id=harmony:egal). + // See the [Harmony `egal` proposal](https://wiki.ecmascript.org/doku.php?id=harmony:egal). if (a === b) return a !== 0 || 1 / a == 1 / b; // A strict comparison is necessary because `null == undefined`. if (a == null || b == null) return a === b; diff --git a/multi/multi__actuator_api.html b/multi/multi__actuator_api.html index f6f2de9e..cd040cc0 100644 --- a/multi/multi__actuator_api.html +++ b/multi/multi__actuator_api.html @@ -40,6 +40,6 @@ "args": {"_genkey_0":"/first"} }], "filters": [], - "uri": "http://www.uri-destination.org", + "uri": "https://www.uri-destination.org", "order": 0 }]

The following table describes the structure of the response.

PathTypeDescription

id

String

The route id.

predicates

Array

The collection of route predicates. Each item defines the name and the arguments of a given predicate.

filters

Array

The collection of filters applied to the route.

uri

String

The destination URI of the route.

order

Number

The route order.

11.5 Creating and deleting a particular route

To create a route, make a POST request to /gateway/routes/{id_route_to_create} with a JSON body that specifies the fields of the route (see the previous subsection).

To delete a route, make a DELETE request to /gateway/routes/{id_route_to_delete}.

11.6 Recap: list of all endpoints

The table below summarises the Spring Cloud Gateway actuator endpoints. Note that each endpoint has /actuator/gateway as the base-path.

IDHTTP MethodDescription

globalfilters

GET

Displays the list of global filters applied to the routes.

routefilters

GET

Displays the list of GatewayFilter factories applied to a particular route.

refresh

POST

Clears the routes cache.

routes

GET

Displays the list of routes defined in the gateway.

routes/{id}

GET

Displays information about a particular route.

routes/{id}

POST

Add a new route to the gateway.

routes/{id}

DELETE

Remove an existing route from the gateway.

\ No newline at end of file diff --git a/multi/multi__configuration.html b/multi/multi__configuration.html index b42dff4a..7ceca4b4 100644 --- a/multi/multi__configuration.html +++ b/multi/multi__configuration.html @@ -10,13 +10,13 @@ gateway: routes: - id: setstatus_route - uri: http://example.org + uri: https://example.org filters: - name: SetStatus args: status: 401 - id: setstatusshortcut_route - uri: http://example.org + uri: https://example.org filters: - SetStatus=401

For some usages of the gateway, properties will be adequate, but some production use cases will benefit from loading configuration from an external source, such as a database. Future milestone versions will have RouteDefinitionLocator implementations based off of Spring Data Repositories such as: Redis, MongoDB and Cassandra.

8.1 Fluent Java Routes API

To allow for simple configuration in Java, there is a fluent API defined in the RouteLocatorBuilder bean.

GatewaySampleApplication.java.  diff --git a/multi/multi__cors_configuration.html b/multi/multi__cors_configuration.html index a18c4c45..610d32b9 100644 --- a/multi/multi__cors_configuration.html +++ b/multi/multi__cors_configuration.html @@ -7,7 +7,7 @@ globalcors: corsConfigurations: '[/**]': - allowedOrigins: "http://docs.spring.io" + allowedOrigins: "https://docs.spring.io" allowedMethods: - GET

In the example above, CORS requests will be allowed from requests that originate from docs.spring.io for all GET requested paths.

\ No newline at end of file diff --git a/multi/multi__gatewayfilter_factories.html b/multi/multi__gatewayfilter_factories.html index 79ccfe14..dfbb4658 100644 --- a/multi/multi__gatewayfilter_factories.html +++ b/multi/multi__gatewayfilter_factories.html @@ -6,7 +6,7 @@ gateway: routes: - id: add_request_header_route - uri: http://example.org + uri: https://example.org filters: - AddRequestHeader=X-Request-Foo, Bar

This will add X-Request-Foo:Bar header to the downstream request’s headers for all matching requests.

5.2 AddRequestParameter GatewayFilter Factory

The AddRequestParameter GatewayFilter Factory takes a name and value parameter.

application.yml.  @@ -15,7 +15,7 @@ gateway: routes: - id: add_request_parameter_route - uri: http://example.org + uri: https://example.org filters: - AddRequestParameter=foo, bar

This will add foo=bar to the downstream request’s query string for all matching requests.

5.3 AddResponseHeader GatewayFilter Factory

The AddResponseHeader GatewayFilter Factory takes a name and value parameter.

application.yml.  @@ -24,17 +24,17 @@ gateway: routes: - id: add_request_header_route - uri: http://example.org + uri: https://example.org filters: - AddResponseHeader=X-Response-Foo, Bar

This will add X-Response-Foo:Bar header to the downstream response’s headers for all matching requests.

5.4 Hystrix GatewayFilter Factory

Hystrix is a library from Netflix that implements the circuit breaker pattern. -The Hystrix GatewayFilter allows you to introduce circuit breakers to your gateway routes, protecting your services from cascading failures and allowing you to provide fallback responses in the event of downstream failures.

To enable Hystrix GatewayFilters in your project, add a dependency on spring-cloud-starter-netflix-hystrix from Spring Cloud Netflix.

The Hystrix GatewayFilter Factory requires a single name parameter, which is the name of the HystrixCommand.

application.yml.  +The Hystrix GatewayFilter allows you to introduce circuit breakers to your gateway routes, protecting your services from cascading failures and allowing you to provide fallback responses in the event of downstream failures.

To enable Hystrix GatewayFilters in your project, add a dependency on spring-cloud-starter-netflix-hystrix from Spring Cloud Netflix.

The Hystrix GatewayFilter Factory requires a single name parameter, which is the name of the HystrixCommand.

application.yml. 

spring:
   cloud:
     gateway:
       routes:
       - id: hystrix_route
-        uri: http://example.org
+        uri: https://example.org
         filters:
         - Hystrix=myCommandName

This wraps the remaining filters in a HystrixCommand with command name myCommandName.

The Hystrix filter can also accept an optional fallbackUri parameter. Currently, only forward: schemed URIs are supported. If the fallback is called, the request will be forwarded to the controller matched by the URI.

application.yml.  @@ -110,7 +110,7 @@ their default values:

    gateway: routes: - id: prefixpath_route - uri: http://example.org + uri: https://example.org filters: - PrefixPath=/mypath

    This will prefix /mypath to the path of all matching requests. So a request to /hello, would be sent to /mypath/hello.

5.7 PreserveHostHeader GatewayFilter Factory

The PreserveHostHeader GatewayFilter Factory has not parameters. This filter, sets a request attribute that the routing filter will inspect to determine if the original host header should be sent, rather than the host header determined by the http client.

application.yml.  @@ -119,7 +119,7 @@ their default values:

    gateway: routes: - id: preserve_host_route - uri: http://example.org + uri: https://example.org filters: - PreserveHostHeader

5.8 RequestRateLimiter GatewayFilter Factory

The RequestRateLimiter GatewayFilter Factory is uses a RateLimiter implementation to determine if the current request is allowed to proceed. If it is not, a status of HTTP 429 - Too Many Requests (by default) is returned.

This filter takes an optional keyResolver parameter and parameters specific to the rate limiter (see below).

keyResolver is a bean that implements the KeyResolver interface. In configuration, reference the bean by name using SpEL. #{@myKeyResolver} is a SpEL expression referencing a bean with the name myKeyResolver.

KeyResolver.java.  @@ -135,7 +135,7 @@ spring.cloud.gateway.routes[0].filters[0]=RequestRateLimiter=2, 2, #{@userkeyres gateway: routes: - id: requestratelimiter_route - uri: http://example.org + uri: https://example.org filters: - name: RequestRateLimiter args: @@ -152,7 +152,7 @@ KeyResolver userKeyResolver() { gateway: routes: - id: requestratelimiter_route - uri: http://example.org + uri: https://example.org filters: - name: RequestRateLimiter args: @@ -164,16 +164,16 @@ KeyResolver userKeyResolver() { gateway: routes: - id: prefixpath_route - uri: http://example.org + uri: https://example.org filters: - - RedirectTo=302, http://acme.org

-

This will send a status 302 with a Location:http://acme.org header to perform a redirect.

5.10 RemoveHopByHopHeadersFilter GatewayFilter Factory

The RemoveHopByHopHeadersFilter GatewayFilter Factory removes headers from forwarded requests. The default list of headers that is removed comes from the IETF.

The default removed headers are:

  • Connection
  • Keep-Alive
  • Proxy-Authenticate
  • Proxy-Authorization
  • TE
  • Trailer
  • Transfer-Encoding
  • Upgrade

To change this, set the spring.cloud.gateway.filter.remove-non-proxy-headers.headers property to the list of header names to remove.

5.11 RemoveRequestHeader GatewayFilter Factory

The RemoveRequestHeader GatewayFilter Factory takes a name parameter. It is the name of the header to be removed.

application.yml.  + - RedirectTo=302, https://acme.org

+

This will send a status 302 with a Location:https://acme.org header to perform a redirect.

5.10 RemoveHopByHopHeadersFilter GatewayFilter Factory

The RemoveHopByHopHeadersFilter GatewayFilter Factory removes headers from forwarded requests. The default list of headers that is removed comes from the IETF.

The default removed headers are:

  • Connection
  • Keep-Alive
  • Proxy-Authenticate
  • Proxy-Authorization
  • TE
  • Trailer
  • Transfer-Encoding
  • Upgrade

To change this, set the spring.cloud.gateway.filter.remove-non-proxy-headers.headers property to the list of header names to remove.

5.11 RemoveRequestHeader GatewayFilter Factory

The RemoveRequestHeader GatewayFilter Factory takes a name parameter. It is the name of the header to be removed.

application.yml. 

spring:
   cloud:
     gateway:
       routes:
       - id: removerequestheader_route
-        uri: http://example.org
+        uri: https://example.org
         filters:
         - RemoveRequestHeader=X-Request-Foo

This will remove the X-Request-Foo header before it is sent downstream.

5.12 RemoveResponseHeader GatewayFilter Factory

The RemoveResponseHeader GatewayFilter Factory takes a name parameter. It is the name of the header to be removed.

application.yml.  @@ -182,7 +182,7 @@ KeyResolver userKeyResolver() { gateway: routes: - id: removeresponseheader_route - uri: http://example.org + uri: https://example.org filters: - RemoveResponseHeader=X-Response-Foo

This will remove the X-Response-Foo header from the response before it is returned to the gateway client.

To remove any kind of sensitive header you should configure this filter for any routes that you may @@ -193,7 +193,7 @@ and have it applied to all routes.

gateway: routes: - id: rewritepath_route - uri: http://example.org + uri: https://example.org predicates: - Path=/foo/** filters: @@ -204,28 +204,28 @@ and have it applied to all routes.

gateway: routes: - id: rewriteresponseheader_route - uri: http://example.org + uri: https://example.org filters: - RewriteResponseHeader=X-Response-Foo, , password=[^&]+, password=***

For a header value of /42?user=ford&password=omg!what&flag=true, it will be set to /42?user=ford&password=***&flag=true after making the downstream request. Please use $\ to mean $ because of the YAML spec.

5.15 SaveSession GatewayFilter Factory

The SaveSession GatewayFilter Factory forces a WebSession::save operation before forwarding the call downstream. This is of particular use when -using something like Spring Session with a lazy data store and need to ensure the session state has been saved before making the forwarded call.

application.yml.  +using something like Spring Session with a lazy data store and need to ensure the session state has been saved before making the forwarded call.

application.yml. 

spring:
   cloud:
     gateway:
       routes:
       - id: save_session
-        uri: http://example.org
+        uri: https://example.org
         predicates:
         - Path=/foo/**
         filters:
         - SaveSession

-

If you are integrating Spring Security with Spring Session, and want to ensure security details have been forwarded to the remote process, this is critical.

5.16 SecureHeaders GatewayFilter Factory

The SecureHeaders GatewayFilter Factory adds a number of headers to the response at the reccomendation from this blog post.

The following headers are added (allong with default values):

  • X-Xss-Protection:1; mode=block
  • Strict-Transport-Security:max-age=631138519
  • X-Frame-Options:DENY
  • X-Content-Type-Options:nosniff
  • Referrer-Policy:no-referrer
  • Content-Security-Policy:default-src 'self' https:; font-src 'self' https: data:; img-src 'self' https: data:; object-src 'none'; script-src https:; style-src 'self' https: 'unsafe-inline'
  • X-Download-Options:noopen
  • X-Permitted-Cross-Domain-Policies:none

To change the default values set the appropriate property in the spring.cloud.gateway.filter.secure-headers namespace:

Property to change:

  • xss-protection-header
  • strict-transport-security
  • frame-options
  • content-type-options
  • referrer-policy
  • content-security-policy
  • download-options
  • permitted-cross-domain-policies

5.17 SetPath GatewayFilter Factory

The SetPath GatewayFilter Factory takes a path template parameter. It offers a simple way to manipulate the request path by allowing templated segments of the path. This uses the uri templates from Spring Framework. Multiple matching segments are allowed.

application.yml.  +

If you are integrating Spring Security with Spring Session, and want to ensure security details have been forwarded to the remote process, this is critical.

5.16 SecureHeaders GatewayFilter Factory

The SecureHeaders GatewayFilter Factory adds a number of headers to the response at the reccomendation from this blog post.

The following headers are added (allong with default values):

  • X-Xss-Protection:1; mode=block
  • Strict-Transport-Security:max-age=631138519
  • X-Frame-Options:DENY
  • X-Content-Type-Options:nosniff
  • Referrer-Policy:no-referrer
  • Content-Security-Policy:default-src 'self' https:; font-src 'self' https: data:; img-src 'self' https: data:; object-src 'none'; script-src https:; style-src 'self' https: 'unsafe-inline'
  • X-Download-Options:noopen
  • X-Permitted-Cross-Domain-Policies:none

To change the default values set the appropriate property in the spring.cloud.gateway.filter.secure-headers namespace:

Property to change:

  • xss-protection-header
  • strict-transport-security
  • frame-options
  • content-type-options
  • referrer-policy
  • content-security-policy
  • download-options
  • permitted-cross-domain-policies

5.17 SetPath GatewayFilter Factory

The SetPath GatewayFilter Factory takes a path template parameter. It offers a simple way to manipulate the request path by allowing templated segments of the path. This uses the uri templates from Spring Framework. Multiple matching segments are allowed.

application.yml. 

spring:
   cloud:
     gateway:
       routes:
       - id: setpath_route
-        uri: http://example.org
+        uri: https://example.org
         predicates:
         - Path=/foo/{segment}
         filters:
@@ -236,7 +236,7 @@ using something like     gateway:
       routes:
       - id: setresponseheader_route
-        uri: http://example.org
+        uri: https://example.org
         filters:
         - SetResponseHeader=X-Response-Foo, Bar

This GatewayFilter replaces all headers with the given name, rather than adding. So if the downstream server responded with a X-Response-Foo:1234, this would be replaced with X-Response-Foo:Bar, which is what the gateway client would receive.

5.19 SetStatus GatewayFilter Factory

The SetStatus GatewayFilter Factory takes a single status parameter. It must be a valid Spring HttpStatus. It may be the integer value 404 or the string representation of the enumeration NOT_FOUND.

application.yml.  @@ -245,11 +245,11 @@ using something like gateway: routes: - id: setstatusstring_route - uri: http://example.org + uri: https://example.org filters: - SetStatus=BAD_REQUEST - id: setstatusint_route - uri: http://example.org + uri: https://example.org filters: - SetStatus=401

In either case, the HTTP status of the response will be set to 401.

5.20 StripPrefix GatewayFilter Factory

The StripPrefix GatewayFilter Factory takes one paramter, parts. The parts parameter indicated the number of parts in the path to strip from the request before sending it downstream.

application.yml.  diff --git a/multi/multi__glossary.html b/multi/multi__glossary.html index 5e16e3f2..83d3d200 100644 --- a/multi/multi__glossary.html +++ b/multi/multi__glossary.html @@ -1,3 +1,3 @@ - 2. Glossary

2. Glossary

  • Route: Route the basic building block of the gateway. It is defined by an ID, a destination URI, a collection of predicates and a collection of filters. A route is matched if aggregate predicate is true.
  • Predicate: This is a Java 8 Function Predicate. The input type is a Spring Framework ServerWebExchange. This allows developers to match on anything from the HTTP request, such as headers or parameters.
  • Filter: These are instances Spring Framework GatewayFilter constructed in with a specific factory. Here, requests and responses can be modified before or after sending the downstream request.
\ No newline at end of file + 2. Glossary

2. Glossary

  • Route: Route the basic building block of the gateway. It is defined by an ID, a destination URI, a collection of predicates and a collection of filters. A route is matched if aggregate predicate is true.
  • Predicate: This is a Java 8 Function Predicate. The input type is a Spring Framework ServerWebExchange. This allows developers to match on anything from the HTTP request, such as headers or parameters.
  • Filter: These are instances Spring Framework GatewayFilter constructed in with a specific factory. Here, requests and responses can be modified before or after sending the downstream request.
\ No newline at end of file diff --git a/multi/multi_gateway-request-predicates-factories.html b/multi/multi_gateway-request-predicates-factories.html index 0e5d34b3..4468ac20 100644 --- a/multi/multi_gateway-request-predicates-factories.html +++ b/multi/multi_gateway-request-predicates-factories.html @@ -6,7 +6,7 @@ gateway: routes: - id: after_route - uri: http://example.org + uri: https://example.org predicates: - After=2017-01-20T17:42:47.789-07:00[America/Denver]

This route matches any request after Jan 20, 2017 17:42 Mountain Time (Denver).

4.2 Before Route Predicate Factory

The Before Route Predicate Factory takes one parameter, a datetime. This predicate matches requests that happen before the current datetime.

application.yml.  @@ -15,7 +15,7 @@ gateway: routes: - id: before_route - uri: http://example.org + uri: https://example.org predicates: - Before=2017-01-20T17:42:47.789-07:00[America/Denver]

This route matches any request before Jan 20, 2017 17:42 Mountain Time (Denver).

4.3 Between Route Predicate Factory

The Between Route Predicate Factory takes two parameters, datetime1 and datetime2. This predicate matches requests that happen after datetime1 and before datetime2. The datetime2 parameter must be after datetime1.

application.yml.  @@ -24,7 +24,7 @@ gateway: routes: - id: between_route - uri: http://example.org + uri: https://example.org predicates: - Between=2017-01-20T17:42:47.789-07:00[America/Denver], 2017-01-21T17:42:47.789-07:00[America/Denver]

This route matches any request after Jan 20, 2017 17:42 Mountain Time (Denver) and before Jan 21, 2017 17:42 Mountain Time (Denver). This could be useful for maintenance windows.

4.4 Cookie Route Predicate Factory

The Cookie Route Predicate Factory takes two parameters, the cookie name and a regular expression. This predicate matches cookies that have the given name and the value matches the regular expression.

application.yml.  @@ -33,7 +33,7 @@ gateway: routes: - id: cookie_route - uri: http://example.org + uri: https://example.org predicates: - Cookie=chocolate, ch.p

This route matches the request has a cookie named chocolate who’s value matches the ch.p regular expression.

4.5 Header Route Predicate Factory

The Header Route Predicate Factory takes two parameters, the header name and a regular expression. This predicate matches with a header that has the given name and the value matches the regular expression.

application.yml.  @@ -42,7 +42,7 @@ gateway: routes: - id: header_route - uri: http://example.org + uri: https://example.org predicates: - Header=X-Request-Id, \d+

This route matches if the request has a header named X-Request-Id whos value matches the \d+ regular expression (has a value of one or more digits).

4.6 Host Route Predicate Factory

The Host Route Predicate Factory takes one parameter: a list of host name patterns. The pattern is an Ant style pattern with . as the separator. This predicates matches the Host header that matches the pattern.

application.yml.  @@ -51,7 +51,7 @@ gateway: routes: - id: host_route - uri: http://example.org + uri: https://example.org predicates: - Host=**.somehost.org,**.anotherhost.org

URI template variables are supported as well, such as {sub}.myhost.org.

This route would match if the request has a Host header has the value www.somehost.org or beta.somehost.org or www.anotherhost.org.

This predicate extracts the URI template variables (like sub defined in the example above) as a map of names and values and places it in the ServerWebExchange.getAttributes() with a key defined in ServerWebExchangeUtils.URI_TEMPLATE_VARIABLES_ATTRIBUTE. Those values are then available for use by GatewayFilter Factories

4.7 Method Route Predicate Factory

The Method Route Predicate Factory takes one parameter: the HTTP method to match.

application.yml.  @@ -60,7 +60,7 @@ gateway: routes: - id: method_route - uri: http://example.org + uri: https://example.org predicates: - Method=GET

This route would match if the request method was a GET.

4.8 Path Route Predicate Factory

The Path Route Predicate Factory takes two parameter: a list of Spring PathMatcher patterns and an optional flag to matchOptionalTrailingSeparator.

application.yml.  @@ -69,7 +69,7 @@ gateway: routes: - id: host_route - uri: http://example.org + uri: https://example.org predicates: - Path=/foo/{segment},/bar/{segment}

This route would match if the request path was, for example: /foo/1 or /foo/bar or /bar/baz.

This predicate extracts the URI template variables (like segment defined in the example above) as a map of names and values and places it in the ServerWebExchange.getAttributes() with a key defined in ServerWebExchangeUtils.URI_TEMPLATE_VARIABLES_ATTRIBUTE. Those values are then available for use by GatewayFilter Factories

A utility method is available to make access to these variables easier.

Map<String, String> uriVariables = ServerWebExchangeUtils.getPathPredicateVariables(exchange);
@@ -80,7 +80,7 @@ String segment = uriVariables.get(    gateway:
       routes:
       - id: query_route
-        uri: http://example.org
+        uri: https://example.org
         predicates:
         - Query=baz

This route would match if the request contained a baz query parameter.

application.yml.  @@ -89,7 +89,7 @@ String segment = uriVariables.get( gateway: routes: - id: query_route - uri: http://example.org + uri: https://example.org predicates: - Query=foo, ba.

This route would match if the request contained a foo query parameter whose value matched the ba. regexp, so bar and baz would match.

4.10 RemoteAddr Route Predicate Factory

The RemoteAddr Route Predicate Factory takes a list (min size 1) of CIDR-notation (IPv4 or IPv6) strings, e.g. 192.168.0.1/16 (where 192.168.0.1 is an IP address and 16 is a subnet mask).

application.yml.  @@ -98,7 +98,7 @@ String segment = uriVariables.get( gateway: routes: - id: remoteaddr_route - uri: http://example.org + uri: https://example.org predicates: - RemoteAddr=192.168.1.1/24

This route would match if the remote address of the request was, for example, 192.168.1.10.

4.10.1 Modifying the way remote addresses are resolved

By default the RemoteAddr Route Predicate Factory uses the remote address from the incoming request. diff --git a/multi/multi_gateway-route-filters.html b/multi/multi_gateway-route-filters.html index 53323acc..fdd14a81 100644 --- a/multi/multi_gateway-route-filters.html +++ b/multi/multi_gateway-route-filters.html @@ -6,7 +6,7 @@ gateway: routes: - id: add_request_header_route - uri: http://example.org + uri: https://example.org filters: - AddRequestHeader=X-Request-Foo, Bar

This will add X-Request-Foo:Bar header to the downstream request’s headers for all matching requests.

5.2 AddRequestParameter GatewayFilter Factory

The AddRequestParameter GatewayFilter Factory takes a name and value parameter.

application.yml.  @@ -15,7 +15,7 @@ gateway: routes: - id: add_request_parameter_route - uri: http://example.org + uri: https://example.org filters: - AddRequestParameter=foo, bar

This will add foo=bar to the downstream request’s query string for all matching requests.

5.3 AddResponseHeader GatewayFilter Factory

The AddResponseHeader GatewayFilter Factory takes a name and value parameter.

application.yml.  @@ -24,7 +24,7 @@ gateway: routes: - id: add_request_header_route - uri: http://example.org + uri: https://example.org filters: - AddResponseHeader=X-Response-Foo, Bar

This will add X-Response-Foo:Bar header to the downstream response’s headers for all matching requests.

5.4 Hystrix GatewayFilter Factory

The Hystrix GatewayFilter Factory requires a single name parameter, which is the name of the HystrixCommand.

application.yml.  @@ -33,7 +33,7 @@ gateway: routes: - id: hystrix_route - uri: http://example.org + uri: https://example.org filters: - Hystrix=myCommandName

This wraps the remaining filters in a HystrixCommand with command name myCommandName.

The Hystrix filter can also accept an optional fallbackUri parameter. Currently, only forward: schemed URIs are supported. If the fallback is called, the request will be forwarded to the controller matched by the URI.

application.yml.  @@ -57,7 +57,7 @@ gateway: routes: - id: prefixpath_route - uri: http://example.org + uri: https://example.org filters: - PrefixPath=/mypath

This will prefix /mypath to the path of all matching requests. So a request to /hello, would be sent to /mypath/hello.

5.6 PreserveHostHeader GatewayFilter Factory

The PreserveHostHeader GatewayFilter Factory has not parameters. This filter, sets a request attribute that the routing filter will inspect to determine if the original host header should be sent, rather than the host header determined by the http client.

application.yml.  @@ -66,7 +66,7 @@ gateway: routes: - id: preserve_host_route - uri: http://example.org + uri: https://example.org filters: - PreserveHostHeader

This will prefix /mypath to the path of all matching requests. So a request to /hello, would be sent to /mypath/hello.

5.7 RequestRateLimiter GatewayFilter Factory

The RequestRateLimiter GatewayFilter Factory takes three parameters: replenishRate, burstCapacity & keyResolverName.

replenishRate is how many requests per second do you want a user to be allowed to do.

burstCapacity TODO: document burst capacity

keyResolver is a bean that implements the KeyResolver interface. In configuration, reference the bean by name using SpEL. #{@myKeyResolver} is a SpEL expression referencing a bean with the name myKeyResolver.

KeyResolver.java.  @@ -79,7 +79,7 @@ gateway: routes: - id: requestratelimiter_route - uri: http://example.org + uri: https://example.org filters: - RequestRateLimiter=10, 20, #{@userKeyResolver}

Config.java.  @@ -93,16 +93,16 @@ KeyResolver userKeyResolver() { gateway: routes: - id: prefixpath_route - uri: http://example.org + uri: https://example.org filters: - - RedirectTo=302, http://acme.org

-

This will send a status 302 with a Location:http://acme.org header to perform a redirect.

5.9 RemoveNonProxyHeaders GatewayFilter Factory

The RemoveNonProxyHeaders GatewayFilter Factory removes headers from forwarded requests. The default list of headers that is removed comes from the IETF.

The default removed headers are:

  • Connection
  • Keep-Alive
  • Proxy-Authenticate
  • Proxy-Authorization
  • TE
  • Trailer
  • Transfer-Encoding
  • Upgrade

To change this, set the spring.cloud.gateway.filter.remove-non-proxy-headers.headers property to the list of header names to remove.

5.10 RemoveRequestHeader GatewayFilter Factory

The RemoveRequestHeader GatewayFilter Factory takes a name parameter. It is the name of the header to be removed.

application.yml.  + - RedirectTo=302, https://acme.org

+

This will send a status 302 with a Location:https://acme.org header to perform a redirect.

5.9 RemoveNonProxyHeaders GatewayFilter Factory

The RemoveNonProxyHeaders GatewayFilter Factory removes headers from forwarded requests. The default list of headers that is removed comes from the IETF.

The default removed headers are:

  • Connection
  • Keep-Alive
  • Proxy-Authenticate
  • Proxy-Authorization
  • TE
  • Trailer
  • Transfer-Encoding
  • Upgrade

To change this, set the spring.cloud.gateway.filter.remove-non-proxy-headers.headers property to the list of header names to remove.

5.10 RemoveRequestHeader GatewayFilter Factory

The RemoveRequestHeader GatewayFilter Factory takes a name parameter. It is the name of the header to be removed.

application.yml. 

spring:
   cloud:
     gateway:
       routes:
       - id: removerequestheader_route
-        uri: http://example.org
+        uri: https://example.org
         filters:
         - RemoveRequestHeader=X-Request-Foo

This will remove the X-Request-Foo header before it is sent downstream.

5.11 RemoveResponseHeader GatewayFilter Factory

The RemoveResponseHeader GatewayFilter Factory takes a name parameter. It is the name of the header to be removed.

application.yml.  @@ -111,7 +111,7 @@ KeyResolver userKeyResolver() { gateway: routes: - id: removeresponseheader_route - uri: http://example.org + uri: https://example.org filters: - RemoveResponseHeader=X-Response-Foo

This will remove the X-Response-Foo header from the response before it is returned to the gateway client.

5.12 RewritePath GatewayFilter Factory

The RewritePath GatewayFilter Factory takes a path regexp parameter and a replacement parameter. This uses Java regular expressions for a flexible way to rewrite the request path.

application.yml.  @@ -120,30 +120,30 @@ KeyResolver userKeyResolver() { gateway: routes: - id: rewritepath_route - uri: http://example.org + uri: https://example.org predicates: - Path=/foo/** filters: - RewritePath=/foo/(?<segment>.*), /$\{segment}

For a request path of /foo/bar, this will set the path to /bar before making the downstream request. Notice the $\ which is replaced with $ because of the YAML spec.

5.13 SaveSession GatewayFilter Factory

The SaveSession GatewayFilter Factory forces a WebSession::save operation before forwarding the call downstream. This is of particular use when -using something like Spring Session with a lazy data store and need to ensure the session state has been saved before making the forwarded call.

application.yml.  +using something like Spring Session with a lazy data store and need to ensure the session state has been saved before making the forwarded call.

application.yml. 

spring:
   cloud:
     gateway:
       routes:
       - id: save_session
-        uri: http://example.org
+        uri: https://example.org
         predicates:
         - Path=/foo/**
         filters:
         - SaveSession

-

If you are integrating Spring Security with Spring Session, and want to ensure security details have been forwarded to the remote process, this is critical.

5.14 SecureHeaders GatewayFilter Factory

The SecureHeaders GatewayFilter Factory adds a number of headers to the response at the reccomendation from this blog post.

The following headers are added (allong with default values):

  • X-Xss-Protection:1; mode=block
  • Strict-Transport-Security:max-age=631138519
  • X-Frame-Options:DENY
  • X-Content-Type-Options:nosniff
  • Referrer-Policy:no-referrer
  • Content-Security-Policy:default-src 'self' https:; font-src 'self' https: data:; img-src 'self' https: data:; object-src 'none'; script-src https:; style-src 'self' https: 'unsafe-inline'
  • X-Download-Options:noopen
  • X-Permitted-Cross-Domain-Policies:none

To change the default values set the appropriate property in the spring.cloud.gateway.filter.secure-headers namespace:

Property to change:

  • xss-protection-header
  • strict-transport-security
  • frame-options
  • content-type-options
  • referrer-policy
  • content-security-policy
  • download-options
  • permitted-cross-domain-policies

5.15 SetPath GatewayFilter Factory

The SetPath GatewayFilter Factory takes a path template parameter. It offers a simple way to manipulate the request path by allowing templated segments of the path. This uses the uri templates from Spring Framework. Multiple matching segments are allowed.

application.yml.  +

If you are integrating Spring Security with Spring Session, and want to ensure security details have been forwarded to the remote process, this is critical.

5.14 SecureHeaders GatewayFilter Factory

The SecureHeaders GatewayFilter Factory adds a number of headers to the response at the reccomendation from this blog post.

The following headers are added (allong with default values):

  • X-Xss-Protection:1; mode=block
  • Strict-Transport-Security:max-age=631138519
  • X-Frame-Options:DENY
  • X-Content-Type-Options:nosniff
  • Referrer-Policy:no-referrer
  • Content-Security-Policy:default-src 'self' https:; font-src 'self' https: data:; img-src 'self' https: data:; object-src 'none'; script-src https:; style-src 'self' https: 'unsafe-inline'
  • X-Download-Options:noopen
  • X-Permitted-Cross-Domain-Policies:none

To change the default values set the appropriate property in the spring.cloud.gateway.filter.secure-headers namespace:

Property to change:

  • xss-protection-header
  • strict-transport-security
  • frame-options
  • content-type-options
  • referrer-policy
  • content-security-policy
  • download-options
  • permitted-cross-domain-policies

5.15 SetPath GatewayFilter Factory

The SetPath GatewayFilter Factory takes a path template parameter. It offers a simple way to manipulate the request path by allowing templated segments of the path. This uses the uri templates from Spring Framework. Multiple matching segments are allowed.

application.yml. 

spring:
   cloud:
     gateway:
       routes:
       - id: setpath_route
-        uri: http://example.org
+        uri: https://example.org
         predicates:
         - Path=/foo/{segment}
         filters:
@@ -154,7 +154,7 @@ using something like     gateway:
       routes:
       - id: setresponseheader_route
-        uri: http://example.org
+        uri: https://example.org
         filters:
         - SetResponseHeader=X-Response-Foo, Bar

This GatewayFilter replaces all headers with the given name, rather than adding. So if the downstream server responded with a X-Response-Foo:1234, this would be replaced with X-Response-Foo:Bar, which is what the gateway client would receive.

5.17 SetStatus GatewayFilter Factory

The SetStatus GatewayFilter Factory takes a single status parameter. It must be a valid Spring HttpStatus. It may be the integer value 404 or the string representation of the enumeration NOT_FOUND.

application.yml.  @@ -163,11 +163,11 @@ using something like gateway: routes: - id: setstatusstring_route - uri: http://example.org + uri: https://example.org filters: - SetStatus=BAD_REQUEST - id: setstatusint_route - uri: http://example.org + uri: https://example.org filters: - SetStatus=401

In either case, the HTTP status of the response will be set to 401.

5.18 StripPrefix GatewayFilter Factory

The StripPrefix GatewayFilter Factory takes one paramter, parts. The parts parameter indicated the number of parts in the path to strip from the request before sending it downstream.

application.yml.  diff --git a/multi/multi_gateway-starter.html b/multi/multi_gateway-starter.html index 023ea515..ec3cf9aa 100644 --- a/multi/multi_gateway-starter.html +++ b/multi/multi_gateway-starter.html @@ -1,7 +1,7 @@ 1. How to Include Spring Cloud Gateway

1. How to Include Spring Cloud Gateway

To include Spring Cloud Gateway in your project use the starter with group org.springframework.cloud -and artifact id spring-cloud-starter-gateway. See the Spring Cloud Project page +and artifact id spring-cloud-starter-gateway. See the Spring Cloud Project page for details on setting up your build system with the current Spring Cloud Release Train.

If you include the starter, but, for some reason, you do not want the gateway to be enabled, set spring.cloud.gateway.enabled=false.

[Important]Important

Spring Cloud Gateway is built upon Spring Boot 2.0, Spring WebFlux, and Project Reactor. As a consequence diff --git a/single/spring-cloud-gateway.html b/single/spring-cloud-gateway.html index 076981f1..6222d2e2 100644 --- a/single/spring-cloud-gateway.html +++ b/single/spring-cloud-gateway.html @@ -1,20 +1,20 @@ Spring Cloud Gateway

Spring Cloud Gateway


Table of Contents

1. How to Include Spring Cloud Gateway
2. Glossary
3. How It Works
4. Route Predicate Factories
4.1. After Route Predicate Factory
4.2. Before Route Predicate Factory
4.3. Between Route Predicate Factory
4.4. Cookie Route Predicate Factory
4.5. Header Route Predicate Factory
4.6. Host Route Predicate Factory
4.7. Method Route Predicate Factory
4.8. Path Route Predicate Factory
4.9. Query Route Predicate Factory
4.10. RemoteAddr Route Predicate Factory
4.10.1. Modifying the way remote addresses are resolved
5. GatewayFilter Factories
5.1. AddRequestHeader GatewayFilter Factory
5.2. AddRequestParameter GatewayFilter Factory
5.3. AddResponseHeader GatewayFilter Factory
5.4. Hystrix GatewayFilter Factory
5.5. FallbackHeaders GatewayFilter Factory
5.6. PrefixPath GatewayFilter Factory
5.7. PreserveHostHeader GatewayFilter Factory
5.8. RequestRateLimiter GatewayFilter Factory
5.8.1. Redis RateLimiter
5.9. RedirectTo GatewayFilter Factory
5.10. RemoveHopByHopHeadersFilter GatewayFilter Factory
5.11. RemoveRequestHeader GatewayFilter Factory
5.12. RemoveResponseHeader GatewayFilter Factory
5.13. RewritePath GatewayFilter Factory
5.14. RewriteResponseHeader GatewayFilter Factory
5.15. SaveSession GatewayFilter Factory
5.16. SecureHeaders GatewayFilter Factory
5.17. SetPath GatewayFilter Factory
5.18. SetResponseHeader GatewayFilter Factory
5.19. SetStatus GatewayFilter Factory
5.20. StripPrefix GatewayFilter Factory
5.21. Retry GatewayFilter Factory
5.22. RequestSize GatewayFilter Factory
5.23. Modify Request Body GatewayFilter Factory
5.24. Modify Response Body GatewayFilter Factory
5.25. Default Filters
6. Global Filters
6.1. Combined Global Filter and GatewayFilter Ordering
6.2. Forward Routing Filter
6.3. LoadBalancerClient Filter
6.4. Netty Routing Filter
6.5. Netty Write Response Filter
6.6. RouteToRequestUrl Filter
6.7. Websocket Routing Filter
6.8. Gateway Metrics Filter
6.9. Marking An Exchange As Routed
7. TLS / SSL
7.1. TLS Handshake
8. Configuration
8.1. Fluent Java Routes API
8.2. DiscoveryClient Route Definition Locator
8.2.1. Configuring Predicates and Filters For DiscoveryClient Routes
9. Reactor Netty Access Logs
10. CORS Configuration
11. Actuator API
11.1. Retrieving route filters
11.1.1. Global Filters
11.1.2. Route Filters
11.2. Refreshing the route cache
11.3. Retrieving the routes defined in the gateway
11.4. Retrieving information about a particular route
11.5. Creating and deleting a particular route
11.6. Recap: list of all endpoints
12. Developer Guide
12.1. Writing Custom Route Predicate Factories
12.2. Writing Custom GatewayFilter Factories
12.3. Writing Custom Global Filters
12.4. Writing Custom Route Locators and Writers
13. Building a Simple Gateway Using Spring MVC or Webflux

2.1.2.BUILD-SNAPSHOT

This project provides an API Gateway built on top of the Spring Ecosystem, including: Spring 5, Spring Boot 2 and Project Reactor. Spring Cloud Gateway aims to provide a simple, yet effective way to route to APIs and provide cross cutting concerns to them such as: security, monitoring/metrics, and resiliency.

1. How to Include Spring Cloud Gateway

To include Spring Cloud Gateway in your project use the starter with group org.springframework.cloud -and artifact id spring-cloud-starter-gateway. See the Spring Cloud Project page +and artifact id spring-cloud-starter-gateway. See the Spring Cloud Project page for details on setting up your build system with the current Spring Cloud Release Train.

If you include the starter, but, for some reason, you do not want the gateway to be enabled, set spring.cloud.gateway.enabled=false.

[Important]Important

Spring Cloud Gateway is built upon Spring Boot 2.0, Spring WebFlux, and Project Reactor. As a consequence many of the familiar synchronous libraries (Spring Data and Spring Security, for example) and patterns you may not apply when using Spring Cloud Gateway. If you are unfamiliar with these projects we suggest you begin by reading their documentation to familiarize yourself with some of the new concepts before -working with Spring Cloud Gateway.

[Important]Important

Spring Cloud Gateway requires the Netty runtime provided by Spring Boot and Spring Webflux. It does not work in a traditional Servlet Container or built as a WAR.

2. Glossary

  • Route: Route the basic building block of the gateway. It is defined by an ID, a destination URI, a collection of predicates and a collection of filters. A route is matched if aggregate predicate is true.
  • Predicate: This is a Java 8 Function Predicate. The input type is a Spring Framework ServerWebExchange. This allows developers to match on anything from the HTTP request, such as headers or parameters.
  • Filter: These are instances Spring Framework GatewayFilter constructed in with a specific factory. Here, requests and responses can be modified before or after sending the downstream request.

3. How It Works

Spring Cloud Gateway Diagram

Clients make requests to Spring Cloud Gateway. If the Gateway Handler Mapping determines that a request matches a Route, it is sent to the Gateway Web Handler. This handler runs sends the request through a filter chain that is specific to the request. The reason the filters are divided by the dotted line, is that filters may execute logic before the proxy request is sent or after. All "pre" filter logic is executed, then the proxy request is made. After the proxy request is made, the "post" filter logic is executed.

[Note]Note

URIs defined in routes without a port will get a default port set to 80 and 443 for HTTP and HTTPS URIs respectively.

4. Route Predicate Factories

Spring Cloud Gateway matches routes as part of the Spring WebFlux HandlerMapping infrastructure. Spring Cloud Gateway includes many built-in Route Predicate Factories. All of these predicates match on different attributes of the HTTP request. Multiple Route Predicate Factories can be combined and are combined via logical and.

4.1 After Route Predicate Factory

The After Route Predicate Factory takes one parameter, a datetime. This predicate matches requests that happen after the current datetime.

application.yml.  +working with Spring Cloud Gateway.

[Important]Important

Spring Cloud Gateway requires the Netty runtime provided by Spring Boot and Spring Webflux. It does not work in a traditional Servlet Container or built as a WAR.

2. Glossary

  • Route: Route the basic building block of the gateway. It is defined by an ID, a destination URI, a collection of predicates and a collection of filters. A route is matched if aggregate predicate is true.
  • Predicate: This is a Java 8 Function Predicate. The input type is a Spring Framework ServerWebExchange. This allows developers to match on anything from the HTTP request, such as headers or parameters.
  • Filter: These are instances Spring Framework GatewayFilter constructed in with a specific factory. Here, requests and responses can be modified before or after sending the downstream request.

3. How It Works

Spring Cloud Gateway Diagram

Clients make requests to Spring Cloud Gateway. If the Gateway Handler Mapping determines that a request matches a Route, it is sent to the Gateway Web Handler. This handler runs sends the request through a filter chain that is specific to the request. The reason the filters are divided by the dotted line, is that filters may execute logic before the proxy request is sent or after. All "pre" filter logic is executed, then the proxy request is made. After the proxy request is made, the "post" filter logic is executed.

[Note]Note

URIs defined in routes without a port will get a default port set to 80 and 443 for HTTP and HTTPS URIs respectively.

4. Route Predicate Factories

Spring Cloud Gateway matches routes as part of the Spring WebFlux HandlerMapping infrastructure. Spring Cloud Gateway includes many built-in Route Predicate Factories. All of these predicates match on different attributes of the HTTP request. Multiple Route Predicate Factories can be combined and are combined via logical and.

4.1 After Route Predicate Factory

The After Route Predicate Factory takes one parameter, a datetime. This predicate matches requests that happen after the current datetime.

application.yml. 

spring:
   cloud:
     gateway:
       routes:
       - id: after_route
-        uri: http://example.org
+        uri: https://example.org
         predicates:
         - After=2017-01-20T17:42:47.789-07:00[America/Denver]

This route matches any request after Jan 20, 2017 17:42 Mountain Time (Denver).

4.2 Before Route Predicate Factory

The Before Route Predicate Factory takes one parameter, a datetime. This predicate matches requests that happen before the current datetime.

application.yml.  @@ -23,7 +23,7 @@ working with Spring Cloud Gateway.

gateway: routes: - id: before_route - uri: http://example.org + uri: https://example.org predicates: - Before=2017-01-20T17:42:47.789-07:00[America/Denver]

This route matches any request before Jan 20, 2017 17:42 Mountain Time (Denver).

4.3 Between Route Predicate Factory

The Between Route Predicate Factory takes two parameters, datetime1 and datetime2. This predicate matches requests that happen after datetime1 and before datetime2. The datetime2 parameter must be after datetime1.

application.yml.  @@ -32,7 +32,7 @@ working with Spring Cloud Gateway.

gateway: routes: - id: between_route - uri: http://example.org + uri: https://example.org predicates: - Between=2017-01-20T17:42:47.789-07:00[America/Denver], 2017-01-21T17:42:47.789-07:00[America/Denver]

This route matches any request after Jan 20, 2017 17:42 Mountain Time (Denver) and before Jan 21, 2017 17:42 Mountain Time (Denver). This could be useful for maintenance windows.

4.4 Cookie Route Predicate Factory

The Cookie Route Predicate Factory takes two parameters, the cookie name and a regular expression. This predicate matches cookies that have the given name and the value matches the regular expression.

application.yml.  @@ -41,7 +41,7 @@ working with Spring Cloud Gateway.

gateway: routes: - id: cookie_route - uri: http://example.org + uri: https://example.org predicates: - Cookie=chocolate, ch.p

This route matches the request has a cookie named chocolate who’s value matches the ch.p regular expression.

4.5 Header Route Predicate Factory

The Header Route Predicate Factory takes two parameters, the header name and a regular expression. This predicate matches with a header that has the given name and the value matches the regular expression.

application.yml.  @@ -50,7 +50,7 @@ working with Spring Cloud Gateway.

gateway: routes: - id: header_route - uri: http://example.org + uri: https://example.org predicates: - Header=X-Request-Id, \d+

This route matches if the request has a header named X-Request-Id whos value matches the \d+ regular expression (has a value of one or more digits).

4.6 Host Route Predicate Factory

The Host Route Predicate Factory takes one parameter: a list of host name patterns. The pattern is an Ant style pattern with . as the separator. This predicates matches the Host header that matches the pattern.

application.yml.  @@ -59,7 +59,7 @@ working with Spring Cloud Gateway.

gateway: routes: - id: host_route - uri: http://example.org + uri: https://example.org predicates: - Host=**.somehost.org,**.anotherhost.org

URI template variables are supported as well, such as {sub}.myhost.org.

This route would match if the request has a Host header has the value www.somehost.org or beta.somehost.org or www.anotherhost.org.

This predicate extracts the URI template variables (like sub defined in the example above) as a map of names and values and places it in the ServerWebExchange.getAttributes() with a key defined in ServerWebExchangeUtils.URI_TEMPLATE_VARIABLES_ATTRIBUTE. Those values are then available for use by GatewayFilter Factories

4.7 Method Route Predicate Factory

The Method Route Predicate Factory takes one parameter: the HTTP method to match.

application.yml.  @@ -68,7 +68,7 @@ working with Spring Cloud Gateway.

gateway: routes: - id: method_route - uri: http://example.org + uri: https://example.org predicates: - Method=GET

This route would match if the request method was a GET.

4.8 Path Route Predicate Factory

The Path Route Predicate Factory takes two parameter: a list of Spring PathMatcher patterns and an optional flag to matchOptionalTrailingSeparator.

application.yml.  @@ -77,7 +77,7 @@ working with Spring Cloud Gateway.

gateway: routes: - id: host_route - uri: http://example.org + uri: https://example.org predicates: - Path=/foo/{segment},/bar/{segment}

This route would match if the request path was, for example: /foo/1 or /foo/bar or /bar/baz.

This predicate extracts the URI template variables (like segment defined in the example above) as a map of names and values and places it in the ServerWebExchange.getAttributes() with a key defined in ServerWebExchangeUtils.URI_TEMPLATE_VARIABLES_ATTRIBUTE. Those values are then available for use by GatewayFilter Factories

A utility method is available to make access to these variables easier.

Map<String, String> uriVariables = ServerWebExchangeUtils.getPathPredicateVariables(exchange);
@@ -88,7 +88,7 @@ String segment = uriVariables.get(    gateway:
       routes:
       - id: query_route
-        uri: http://example.org
+        uri: https://example.org
         predicates:
         - Query=baz

This route would match if the request contained a baz query parameter.

application.yml.  @@ -97,7 +97,7 @@ String segment = uriVariables.get( gateway: routes: - id: query_route - uri: http://example.org + uri: https://example.org predicates: - Query=foo, ba.

This route would match if the request contained a foo query parameter whose value matched the ba. regexp, so bar and baz would match.

4.10 RemoteAddr Route Predicate Factory

The RemoteAddr Route Predicate Factory takes a list (min size 1) of CIDR-notation (IPv4 or IPv6) strings, e.g. 192.168.0.1/16 (where 192.168.0.1 is an IP address and 16 is a subnet mask).

application.yml.  @@ -106,7 +106,7 @@ String segment = uriVariables.get( gateway: routes: - id: remoteaddr_route - uri: http://example.org + uri: https://example.org predicates: - RemoteAddr=192.168.1.1/24

This route would match if the remote address of the request was, for example, 192.168.1.10.

4.10.1 Modifying the way remote addresses are resolved

By default the RemoteAddr Route Predicate Factory uses the remote address from the incoming request. @@ -131,7 +131,7 @@ If two hops of trusted infrastructure are required before Spring Cloud Gateway i gateway: routes: - id: add_request_header_route - uri: http://example.org + uri: https://example.org filters: - AddRequestHeader=X-Request-Foo, Bar

This will add X-Request-Foo:Bar header to the downstream request’s headers for all matching requests.

5.2 AddRequestParameter GatewayFilter Factory

The AddRequestParameter GatewayFilter Factory takes a name and value parameter.

application.yml.  @@ -140,7 +140,7 @@ If two hops of trusted infrastructure are required before Spring Cloud Gateway i gateway: routes: - id: add_request_parameter_route - uri: http://example.org + uri: https://example.org filters: - AddRequestParameter=foo, bar

This will add foo=bar to the downstream request’s query string for all matching requests.

5.3 AddResponseHeader GatewayFilter Factory

The AddResponseHeader GatewayFilter Factory takes a name and value parameter.

application.yml.  @@ -149,17 +149,17 @@ If two hops of trusted infrastructure are required before Spring Cloud Gateway i gateway: routes: - id: add_request_header_route - uri: http://example.org + uri: https://example.org filters: - AddResponseHeader=X-Response-Foo, Bar

This will add X-Response-Foo:Bar header to the downstream response’s headers for all matching requests.

5.4 Hystrix GatewayFilter Factory

Hystrix is a library from Netflix that implements the circuit breaker pattern. -The Hystrix GatewayFilter allows you to introduce circuit breakers to your gateway routes, protecting your services from cascading failures and allowing you to provide fallback responses in the event of downstream failures.

To enable Hystrix GatewayFilters in your project, add a dependency on spring-cloud-starter-netflix-hystrix from Spring Cloud Netflix.

The Hystrix GatewayFilter Factory requires a single name parameter, which is the name of the HystrixCommand.

application.yml.  +The Hystrix GatewayFilter allows you to introduce circuit breakers to your gateway routes, protecting your services from cascading failures and allowing you to provide fallback responses in the event of downstream failures.

To enable Hystrix GatewayFilters in your project, add a dependency on spring-cloud-starter-netflix-hystrix from Spring Cloud Netflix.

The Hystrix GatewayFilter Factory requires a single name parameter, which is the name of the HystrixCommand.

application.yml. 

spring:
   cloud:
     gateway:
       routes:
       - id: hystrix_route
-        uri: http://example.org
+        uri: https://example.org
         filters:
         - Hystrix=myCommandName

This wraps the remaining filters in a HystrixCommand with command name myCommandName.

The Hystrix filter can also accept an optional fallbackUri parameter. Currently, only forward: schemed URIs are supported. If the fallback is called, the request will be forwarded to the controller matched by the URI.

application.yml.  @@ -235,7 +235,7 @@ their default values:

    gateway: routes: - id: prefixpath_route - uri: http://example.org + uri: https://example.org filters: - PrefixPath=/mypath

    This will prefix /mypath to the path of all matching requests. So a request to /hello, would be sent to /mypath/hello.

5.7 PreserveHostHeader GatewayFilter Factory

The PreserveHostHeader GatewayFilter Factory has not parameters. This filter, sets a request attribute that the routing filter will inspect to determine if the original host header should be sent, rather than the host header determined by the http client.

application.yml.  @@ -244,7 +244,7 @@ their default values:

    gateway: routes: - id: preserve_host_route - uri: http://example.org + uri: https://example.org filters: - PreserveHostHeader

5.8 RequestRateLimiter GatewayFilter Factory

The RequestRateLimiter GatewayFilter Factory is uses a RateLimiter implementation to determine if the current request is allowed to proceed. If it is not, a status of HTTP 429 - Too Many Requests (by default) is returned.

This filter takes an optional keyResolver parameter and parameters specific to the rate limiter (see below).

keyResolver is a bean that implements the KeyResolver interface. In configuration, reference the bean by name using SpEL. #{@myKeyResolver} is a SpEL expression referencing a bean with the name myKeyResolver.

KeyResolver.java.  @@ -260,7 +260,7 @@ spring.cloud.gateway.routes[0].filters[0]=RequestRateLimiter=2, 2, #{@userkeyres gateway: routes: - id: requestratelimiter_route - uri: http://example.org + uri: https://example.org filters: - name: RequestRateLimiter args: @@ -277,7 +277,7 @@ KeyResolver userKeyResolver() { gateway: routes: - id: requestratelimiter_route - uri: http://example.org + uri: https://example.org filters: - name: RequestRateLimiter args: @@ -289,16 +289,16 @@ KeyResolver userKeyResolver() { gateway: routes: - id: prefixpath_route - uri: http://example.org + uri: https://example.org filters: - - RedirectTo=302, http://acme.org

-

This will send a status 302 with a Location:http://acme.org header to perform a redirect.

5.10 RemoveHopByHopHeadersFilter GatewayFilter Factory

The RemoveHopByHopHeadersFilter GatewayFilter Factory removes headers from forwarded requests. The default list of headers that is removed comes from the IETF.

The default removed headers are:

  • Connection
  • Keep-Alive
  • Proxy-Authenticate
  • Proxy-Authorization
  • TE
  • Trailer
  • Transfer-Encoding
  • Upgrade

To change this, set the spring.cloud.gateway.filter.remove-non-proxy-headers.headers property to the list of header names to remove.

5.11 RemoveRequestHeader GatewayFilter Factory

The RemoveRequestHeader GatewayFilter Factory takes a name parameter. It is the name of the header to be removed.

application.yml.  + - RedirectTo=302, https://acme.org

+

This will send a status 302 with a Location:https://acme.org header to perform a redirect.

5.10 RemoveHopByHopHeadersFilter GatewayFilter Factory

The RemoveHopByHopHeadersFilter GatewayFilter Factory removes headers from forwarded requests. The default list of headers that is removed comes from the IETF.

The default removed headers are:

  • Connection
  • Keep-Alive
  • Proxy-Authenticate
  • Proxy-Authorization
  • TE
  • Trailer
  • Transfer-Encoding
  • Upgrade

To change this, set the spring.cloud.gateway.filter.remove-non-proxy-headers.headers property to the list of header names to remove.

5.11 RemoveRequestHeader GatewayFilter Factory

The RemoveRequestHeader GatewayFilter Factory takes a name parameter. It is the name of the header to be removed.

application.yml. 

spring:
   cloud:
     gateway:
       routes:
       - id: removerequestheader_route
-        uri: http://example.org
+        uri: https://example.org
         filters:
         - RemoveRequestHeader=X-Request-Foo

This will remove the X-Request-Foo header before it is sent downstream.

5.12 RemoveResponseHeader GatewayFilter Factory

The RemoveResponseHeader GatewayFilter Factory takes a name parameter. It is the name of the header to be removed.

application.yml.  @@ -307,7 +307,7 @@ KeyResolver userKeyResolver() { gateway: routes: - id: removeresponseheader_route - uri: http://example.org + uri: https://example.org filters: - RemoveResponseHeader=X-Response-Foo

This will remove the X-Response-Foo header from the response before it is returned to the gateway client.

To remove any kind of sensitive header you should configure this filter for any routes that you may @@ -318,7 +318,7 @@ and have it applied to all routes.

gateway: routes: - id: rewritepath_route - uri: http://example.org + uri: https://example.org predicates: - Path=/foo/** filters: @@ -329,28 +329,28 @@ and have it applied to all routes.

gateway: routes: - id: rewriteresponseheader_route - uri: http://example.org + uri: https://example.org filters: - RewriteResponseHeader=X-Response-Foo, , password=[^&]+, password=***

For a header value of /42?user=ford&password=omg!what&flag=true, it will be set to /42?user=ford&password=***&flag=true after making the downstream request. Please use $\ to mean $ because of the YAML spec.

5.15 SaveSession GatewayFilter Factory

The SaveSession GatewayFilter Factory forces a WebSession::save operation before forwarding the call downstream. This is of particular use when -using something like Spring Session with a lazy data store and need to ensure the session state has been saved before making the forwarded call.

application.yml.  +using something like Spring Session with a lazy data store and need to ensure the session state has been saved before making the forwarded call.

application.yml. 

spring:
   cloud:
     gateway:
       routes:
       - id: save_session
-        uri: http://example.org
+        uri: https://example.org
         predicates:
         - Path=/foo/**
         filters:
         - SaveSession

-

If you are integrating Spring Security with Spring Session, and want to ensure security details have been forwarded to the remote process, this is critical.

5.16 SecureHeaders GatewayFilter Factory

The SecureHeaders GatewayFilter Factory adds a number of headers to the response at the reccomendation from this blog post.

The following headers are added (allong with default values):

  • X-Xss-Protection:1; mode=block
  • Strict-Transport-Security:max-age=631138519
  • X-Frame-Options:DENY
  • X-Content-Type-Options:nosniff
  • Referrer-Policy:no-referrer
  • Content-Security-Policy:default-src 'self' https:; font-src 'self' https: data:; img-src 'self' https: data:; object-src 'none'; script-src https:; style-src 'self' https: 'unsafe-inline'
  • X-Download-Options:noopen
  • X-Permitted-Cross-Domain-Policies:none

To change the default values set the appropriate property in the spring.cloud.gateway.filter.secure-headers namespace:

Property to change:

  • xss-protection-header
  • strict-transport-security
  • frame-options
  • content-type-options
  • referrer-policy
  • content-security-policy
  • download-options
  • permitted-cross-domain-policies

5.17 SetPath GatewayFilter Factory

The SetPath GatewayFilter Factory takes a path template parameter. It offers a simple way to manipulate the request path by allowing templated segments of the path. This uses the uri templates from Spring Framework. Multiple matching segments are allowed.

application.yml.  +

If you are integrating Spring Security with Spring Session, and want to ensure security details have been forwarded to the remote process, this is critical.

5.16 SecureHeaders GatewayFilter Factory

The SecureHeaders GatewayFilter Factory adds a number of headers to the response at the reccomendation from this blog post.

The following headers are added (allong with default values):

  • X-Xss-Protection:1; mode=block
  • Strict-Transport-Security:max-age=631138519
  • X-Frame-Options:DENY
  • X-Content-Type-Options:nosniff
  • Referrer-Policy:no-referrer
  • Content-Security-Policy:default-src 'self' https:; font-src 'self' https: data:; img-src 'self' https: data:; object-src 'none'; script-src https:; style-src 'self' https: 'unsafe-inline'
  • X-Download-Options:noopen
  • X-Permitted-Cross-Domain-Policies:none

To change the default values set the appropriate property in the spring.cloud.gateway.filter.secure-headers namespace:

Property to change:

  • xss-protection-header
  • strict-transport-security
  • frame-options
  • content-type-options
  • referrer-policy
  • content-security-policy
  • download-options
  • permitted-cross-domain-policies

5.17 SetPath GatewayFilter Factory

The SetPath GatewayFilter Factory takes a path template parameter. It offers a simple way to manipulate the request path by allowing templated segments of the path. This uses the uri templates from Spring Framework. Multiple matching segments are allowed.

application.yml. 

spring:
   cloud:
     gateway:
       routes:
       - id: setpath_route
-        uri: http://example.org
+        uri: https://example.org
         predicates:
         - Path=/foo/{segment}
         filters:
@@ -361,7 +361,7 @@ using something like     gateway:
       routes:
       - id: setresponseheader_route
-        uri: http://example.org
+        uri: https://example.org
         filters:
         - SetResponseHeader=X-Response-Foo, Bar

This GatewayFilter replaces all headers with the given name, rather than adding. So if the downstream server responded with a X-Response-Foo:1234, this would be replaced with X-Response-Foo:Bar, which is what the gateway client would receive.

5.19 SetStatus GatewayFilter Factory

The SetStatus GatewayFilter Factory takes a single status parameter. It must be a valid Spring HttpStatus. It may be the integer value 404 or the string representation of the enumeration NOT_FOUND.

application.yml.  @@ -370,11 +370,11 @@ using something like gateway: routes: - id: setstatusstring_route - uri: http://example.org + uri: https://example.org filters: - SetStatus=BAD_REQUEST - id: setstatusint_route - uri: http://example.org + uri: https://example.org filters: - SetStatus=401

In either case, the HTTP status of the response will be set to 401.

5.20 StripPrefix GatewayFilter Factory

The StripPrefix GatewayFilter Factory takes one paramter, parts. The parts parameter indicated the number of parts in the path to strip from the request before sending it downstream.

application.yml.  @@ -566,13 +566,13 @@ or check if an exchange has already been routed.

gateway: routes: - id: setstatus_route - uri: http://example.org + uri: https://example.org filters: - name: SetStatus args: status: 401 - id: setstatusshortcut_route - uri: http://example.org + uri: https://example.org filters: - SetStatus=401

For some usages of the gateway, properties will be adequate, but some production use cases will benefit from loading configuration from an external source, such as a database. Future milestone versions will have RouteDefinitionLocator implementations based off of Spring Data Repositories such as: Redis, MongoDB and Cassandra.

8.1 Fluent Java Routes API

To allow for simple configuration in Java, there is a fluent API defined in the RouteLocatorBuilder bean.

GatewaySampleApplication.java.  @@ -637,7 +637,7 @@ spring.cloud.gateway.discovery.locator.filters[1].args[replacement]: "'/${remain globalcors: corsConfigurations: '[/**]': - allowedOrigins: "http://docs.spring.io" + allowedOrigins: "https://docs.spring.io" allowedMethods: - GET

In the example above, CORS requests will be allowed from requests that originate from docs.spring.io for all GET requested paths.

11. Actuator API

The /gateway actuator endpoint allows to monitor and interact with a Spring Cloud Gateway application. To be remotely accessible, the endpoint has to be enabled and exposed via HTTP or JMX in the application properties.

application.properties.  @@ -680,7 +680,7 @@ spring.cloud.gateway.discovery.locator.filters[1].args[replacement]: "'/${remain "args": {"_genkey_0":"/first"} }], "filters": [], - "uri": "http://www.uri-destination.org", + "uri": "https://www.uri-destination.org", "order": 0 }]

The following table describes the structure of the response.

PathTypeDescription

id

String

The route id.

predicates

Array

The collection of route predicates. Each item defines the name and the arguments of a given predicate.

filters

Array

The collection of filters applied to the route.

uri

String

The destination URI of the route.

order

Number

The route order.

11.5 Creating and deleting a particular route

To create a route, make a POST request to /gateway/routes/{id_route_to_create} with a JSON body that specifies the fields of the route (see the previous subsection).

To delete a route, make a DELETE request to /gateway/routes/{id_route_to_delete}.

11.6 Recap: list of all endpoints

The table below summarises the Spring Cloud Gateway actuator endpoints. Note that each endpoint has /actuator/gateway as the base-path.

IDHTTP MethodDescription

globalfilters

GET

Displays the list of global filters applied to the routes.

routefilters

GET

Displays the list of GatewayFilter factories applied to a particular route.

refresh

POST

Clears the routes cache.

routes

GET

Displays the list of routes defined in the gateway.

routes/{id}

GET

Displays information about a particular route.

routes/{id}

POST

Add a new route to the gateway.

routes/{id}

DELETE

Remove an existing route from the gateway.

12. Developer Guide

TODO: overview of writing custom integrations

12.1 Writing Custom Route Predicate Factories

TODO: document writing Custom Route Predicate Factories

12.2 Writing Custom GatewayFilter Factories

In order to write a GatewayFilter you will need to implement GatewayFilterFactory. There is an abstract class called AbstractGatewayFilterFactory which you can extend.

PreGatewayFilterFactory.java. 

public class PreGatewayFilterFactory extends AbstractGatewayFilterFactory<PreGatewayFilterFactory.Config> {
diff --git a/spring-cloud-gateway.html b/spring-cloud-gateway.html
index e508fdda..4690d41b 100644
--- a/spring-cloud-gateway.html
+++ b/spring-cloud-gateway.html
@@ -33,7 +33,7 @@
 	color: #ffffff;
 }
 
-
+