diff --git a/multi/multi_gateway-route-filters.html b/multi/multi_gateway-route-filters.html index bb3414c2..f0d78312 100644 --- a/multi/multi_gateway-route-filters.html +++ b/multi/multi_gateway-route-filters.html @@ -50,7 +50,17 @@ uri: http://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.
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. +
This will prefix /mypath to the path of all matching requests. So a request to /hello, would be sent to /mypath/hello.
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. +
spring: + cloud: + gateway: + routes: + # ===================================== + - id: preserve_host_route + uri: http://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.
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.
public interface KeyResolver { Mono<String> resolve(ServerWebExchange exchange); }
@@ -69,7 +79,7 @@ KeyResolver userKeyResolver() { return exchange -> Mono.just(exchange.getRequest().getQueryParams().getFirst("user")); }
-
This defines a request rate limit of 10 per user. The KeyResolver is a simple one that gets the user request parameter (note: this is not recommended for production).
The RedirectTo GatewayFilter Factory takes a status and a url parameter. The status should be a 300 series redirect http code, such as 301. The url should be a valid url. This will be the value of the Location header.
application.yml. +
This defines a request rate limit of 10 per user. The KeyResolver is a simple one that gets the user request parameter (note: this is not recommended for production).
The RedirectTo GatewayFilter Factory takes a status and a url parameter. The status should be a 300 series redirect http code, such as 301. The url should be a valid url. This will be the value of the Location header.
application.yml.
spring: cloud: gateway: @@ -79,7 +89,7 @@ KeyResolver userKeyResolver() { uri: http://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.
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:
To change this, set the spring.cloud.gateway.filter.remove-non-proxy-headers.headers property to the list of header names to remove.
The RemoveRequestHeader GatewayFilter Factory takes a name parameter. It is the name of the header to be removed.
application.yml. +
This will send a status 302 with a Location:http://acme.org header to perform a redirect.
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:
To change this, set the spring.cloud.gateway.filter.remove-non-proxy-headers.headers property to the list of header names to remove.
The RemoveRequestHeader GatewayFilter Factory takes a name parameter. It is the name of the header to be removed.
application.yml.
spring: cloud: gateway: @@ -89,7 +99,7 @@ KeyResolver userKeyResolver() { uri: http://example.org filters: - RemoveRequestHeader=X-Request-Foo
-
This will remove the X-Request-Foo header before it is sent downstream.
The RemoveResponseHeader GatewayFilter Factory takes a name parameter. It is the name of the header to be removed.
application.yml. +
This will remove the X-Request-Foo header before it is sent downstream.
The RemoveResponseHeader GatewayFilter Factory takes a name parameter. It is the name of the header to be removed.
application.yml.
spring: cloud: gateway: @@ -99,7 +109,7 @@ KeyResolver userKeyResolver() { uri: http://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.
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. +
This will remove the X-Response-Foo header from the response before it is returned to the gateway client.
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.
spring: cloud: gateway: @@ -111,7 +121,7 @@ KeyResolver userKeyResolver() { - 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.
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=blockStrict-Transport-Security:max-age=631138519X-Frame-Options:DENYX-Content-Type-Options:nosniffReferrer-Policy:no-referrerContent-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:noopenX-Permitted-Cross-Domain-Policies:noneTo change the default values set the appropriate property in the spring.cloud.gateway.filter.secure-headers namespace:
Property to change:
xss-protection-headerstrict-transport-securityframe-optionscontent-type-optionsreferrer-policycontent-security-policydownload-optionspermitted-cross-domain-policiesThe 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. +
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.
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=blockStrict-Transport-Security:max-age=631138519X-Frame-Options:DENYX-Content-Type-Options:nosniffReferrer-Policy:no-referrerContent-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:noopenX-Permitted-Cross-Domain-Policies:noneTo change the default values set the appropriate property in the spring.cloud.gateway.filter.secure-headers namespace:
Property to change:
xss-protection-headerstrict-transport-securityframe-optionscontent-type-optionsreferrer-policycontent-security-policydownload-optionspermitted-cross-domain-policiesThe 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: @@ -123,7 +133,7 @@ KeyResolver userKeyResolver() { - Path=/foo/{segment} filters: - SetPath=/{segment}
-
For a request path of /foo/bar, this will set the path to /bar before making the downstream request.
The SetResponseHeader GatewayFilter Factory takes name and value parameters.
application.yml. +
For a request path of /foo/bar, this will set the path to /bar before making the downstream request.
The SetResponseHeader GatewayFilter Factory takes name and value parameters.
application.yml.
spring: cloud: gateway: @@ -133,7 +143,7 @@ KeyResolver userKeyResolver() { uri: http://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.
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. +
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.
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.
spring: cloud: gateway: diff --git a/multi/multi_spring-cloud-gateway.html b/multi/multi_spring-cloud-gateway.html index b217eeb4..6f75eb4f 100644 --- a/multi/multi_spring-cloud-gateway.html +++ b/multi/multi_spring-cloud-gateway.html @@ -1,3 +1,3 @@ -Spring Cloud Gateway \ No newline at end of file +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
- 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. PrefixPath GatewayFilter Factory
- 5.6. RequestRateLimiter GatewayFilter Factory
- 5.7. RedirectTo GatewayFilter Factory
- 5.8. RemoveNonProxyHeaders GatewayFilter Factory
- 5.9. RemoveRequestHeader GatewayFilter Factory
- 5.10. RemoveResponseHeader GatewayFilter Factory
- 5.11. RewritePath GatewayFilter Factory
- 5.12. SecureHeaders GatewayFilter Factory
- 5.13. SetPath GatewayFilter Factory
- 5.14. SetResponseHeader GatewayFilter Factory
- 5.15. SetStatus GatewayFilter Factory
- 6. Global Filters
- 7. Configuration
- 8. Actuator API
- 9. Developer Guide
- 10. Building a Simple Gateway Using Spring MVC
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
- 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. PrefixPath GatewayFilter Factory
- 5.6. PreserveHostHeader GatewayFilter Factory
- 5.7. RequestRateLimiter GatewayFilter Factory
- 5.8. RedirectTo GatewayFilter Factory
- 5.9. RemoveNonProxyHeaders GatewayFilter Factory
- 5.10. RemoveRequestHeader GatewayFilter Factory
- 5.11. RemoveResponseHeader GatewayFilter Factory
- 5.12. RewritePath GatewayFilter Factory
- 5.13. SecureHeaders GatewayFilter Factory
- 5.14. SetPath GatewayFilter Factory
- 5.15. SetResponseHeader GatewayFilter Factory
- 5.16. SetStatus GatewayFilter Factory
- 6. Global Filters
- 7. Configuration
- 8. Actuator API
- 9. Developer Guide
- 10. Building a Simple Gateway Using Spring MVC