diff --git a/multi/multi__gatewayfilter_factories.html b/multi/multi__gatewayfilter_factories.html index da938750..05ee8fbb 100644 --- a/multi/multi__gatewayfilter_factories.html +++ b/multi/multi__gatewayfilter_factories.html @@ -196,7 +196,16 @@ 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 SaveSession GatewayFilter Factory forces a WebSession::save operation before forwarding the call downstream. This is of particular use when
+
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 RewriteResponseHeader GatewayFilter Factory takes name, regexp, and replacement parameters. It uses Java regular expressions for a flexible way to rewrite the response header value.
application.yml. +
spring: + cloud: + gateway: + routes: + - id: rewriteresponseheader_route + uri: http://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.
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: @@ -208,7 +217,7 @@ using something like - 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. +
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: @@ -219,7 +228,7 @@ using something like - 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: @@ -228,7 +237,7 @@ using something like 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: @@ -241,7 +250,7 @@ using something like uri: http://example.org filters: - SetStatus=401
-
In either case, the HTTP status of the response will be set to 401.
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. +
In either case, the HTTP status of the response will be set to 401.
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.
spring: cloud: gateway: @@ -252,7 +261,7 @@ using something like - Path=/name/** filters: - StripPrefix=2
-
When a request is made through the gateway to /name/bar/foo the request made to nameservice will look like http://nameservice/foo.
The Retry GatewayFilter Factory takes retries, statuses, methods, and series as parameters.
retries: the number of retries that should be attemptedstatuses: the HTTP status codes that should be retried, represented using org.springframework.http.HttpStatusmethods: the HTTP methods that should be retried, represented using org.springframework.http.HttpMethodseries: the series of status codes to be retried, represented using org.springframework.http.HttpStatus.Seriesapplication.yml. +
When a request is made through the gateway to /name/bar/foo the request made to nameservice will look like http://nameservice/foo.
The Retry GatewayFilter Factory takes retries, statuses, methods, and series as parameters.
retries: the number of retries that should be attemptedstatuses: the HTTP status codes that should be retried, represented using org.springframework.http.HttpStatusmethods: the HTTP methods that should be retried, represented using org.springframework.http.HttpMethodseries: the series of status codes to be retried, represented using org.springframework.http.HttpStatus.Seriesapplication.yml.
spring: cloud: gateway: @@ -266,7 +275,7 @@ using something like args: retries: 3 statuses: BAD_GATEWAY
-
![]() | Note |
|---|---|
When using the retry filter with a |
The RequestSize GatewayFilter Factory can restrict a request from reaching the downstream service , when the request size is greater than the permissible limit. The filter takes RequestSize as parameter which is the permissible size limit of the request defined in bytes.
application.yml. +
![]() | Note |
|---|---|
When using the retry filter with a |
The RequestSize GatewayFilter Factory can restrict a request from reaching the downstream service , when the request size is greater than the permissible limit. The filter takes RequestSize as parameter which is the permissible size limit of the request defined in bytes.
application.yml.
spring: cloud: gateway: diff --git a/multi/multi_spring-cloud-gateway.html b/multi/multi_spring-cloud-gateway.html index 89409eda..bb3323fa 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. FallbackHeaders GatewayFilter Factory
- 5.6. PrefixPath GatewayFilter Factory
- 5.7. PreserveHostHeader GatewayFilter Factory
- 5.8. RequestRateLimiter GatewayFilter Factory
- 5.9. RedirectTo GatewayFilter Factory
- 5.10. RemoveNonProxyHeaders GatewayFilter Factory
- 5.11. RemoveRequestHeader GatewayFilter Factory
- 5.12. RemoveResponseHeader GatewayFilter Factory
- 5.13. RewritePath GatewayFilter Factory
- 5.14. SaveSession GatewayFilter Factory
- 5.15. SecureHeaders GatewayFilter Factory
- 5.16. SetPath GatewayFilter Factory
- 5.17. SetResponseHeader GatewayFilter Factory
- 5.18. SetStatus GatewayFilter Factory
- 5.19. StripPrefix GatewayFilter Factory
- 5.20. Retry GatewayFilter Factory
- 5.21. RequestSize GatewayFilter Factory
- 6. Global Filters
- 7. TLS / SSL
- 8. Configuration
- 9. Reactor Netty Access Logs
- 10. CORS Configuration
- 11. Actuator API
- 12. Developer Guide
- 13. Building a Simple Gateway Using Spring MVC or Webflux
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. FallbackHeaders GatewayFilter Factory
- 5.6. PrefixPath GatewayFilter Factory
- 5.7. PreserveHostHeader GatewayFilter Factory
- 5.8. RequestRateLimiter GatewayFilter Factory
- 5.9. RedirectTo GatewayFilter Factory
- 5.10. RemoveNonProxyHeaders 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
- 6. Global Filters
- 7. TLS / SSL
- 8. Configuration
- 9. Reactor Netty Access Logs
- 10. CORS Configuration
- 11. Actuator API
- 12. Developer Guide
- 13. Building a Simple Gateway Using Spring MVC or Webflux