diff --git a/multi/multi_gateway-route-filters.html b/multi/multi_gateway-route-filters.html index 81bd1452..5834a450 100644 --- a/multi/multi_gateway-route-filters.html +++ b/multi/multi_gateway-route-filters.html @@ -124,7 +124,19 @@ 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 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. +
spring: + cloud: + gateway: + routes: + - id: save_session + uri: http://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.
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: @@ -135,7 +147,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: @@ -144,7 +156,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 6f75eb4f..b11b9b74 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. 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
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. SaveSession GatewayFilter Factory
- 5.14. SecureHeaders GatewayFilter Factory
- 5.15. SetPath GatewayFilter Factory
- 5.16. SetResponseHeader GatewayFilter Factory
- 5.17. SetStatus GatewayFilter Factory
- 6. Global Filters
- 7. Configuration
- 8. Actuator API
- 9. Developer Guide
- 10. Building a Simple Gateway Using Spring MVC