Merge remote-tracking branch 'spring-operator/polish-urls-remaining-master'
This commit is contained in:
@@ -16,7 +16,7 @@ include::intro.adoc[]
|
||||
== 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 http://projects.spring.io/spring-cloud/[Spring Cloud Project page]
|
||||
and artifact id `spring-cloud-starter-gateway`. See the https://projects.spring.io/spring-cloud/[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`.
|
||||
@@ -34,8 +34,8 @@ IMPORTANT: Spring Cloud Gateway requires the Netty runtime provided by Spring Bo
|
||||
== 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 http://docs.oracle.com/javase/8/docs/api/java/util/function/Predicate.html[Java 8 Function Predicate]. The input type is a http://docs.spring.io/spring/docs/5.0.x/javadoc-api/org/springframework/web/server/ServerWebExchange.html[Spring Framework `ServerWebExchange`]. This allows developers to match on anything from the HTTP request, such as headers or parameters.
|
||||
* *Filter*: These are instances http://docs.spring.io/spring/docs/5.0.x/javadoc-api/org/springframework/web/server/GatewayFilter.html[Spring Framework `GatewayFilter`] constructed in with a specific factory. Here, requests and responses can be modified before or after sending the downstream request.
|
||||
* *Predicate*: This is a https://docs.oracle.com/javase/8/docs/api/java/util/function/Predicate.html[Java 8 Function Predicate]. The input type is a https://docs.spring.io/spring/docs/5.0.x/javadoc-api/org/springframework/web/server/ServerWebExchange.html[Spring Framework `ServerWebExchange`]. This allows developers to match on anything from the HTTP request, such as headers or parameters.
|
||||
* *Filter*: These are instances https://docs.spring.io/spring/docs/5.0.x/javadoc-api/org/springframework/web/server/GatewayFilter.html[Spring Framework `GatewayFilter`] constructed in with a specific factory. Here, requests and responses can be modified before or after sending the downstream request.
|
||||
|
||||
[[gateway-how-it-works]]
|
||||
== How It Works
|
||||
@@ -62,7 +62,7 @@ spring:
|
||||
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]
|
||||
----
|
||||
@@ -80,7 +80,7 @@ spring:
|
||||
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]
|
||||
----
|
||||
@@ -98,7 +98,7 @@ spring:
|
||||
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]
|
||||
----
|
||||
@@ -116,7 +116,7 @@ spring:
|
||||
gateway:
|
||||
routes:
|
||||
- id: cookie_route
|
||||
uri: http://example.org
|
||||
uri: https://example.org
|
||||
predicates:
|
||||
- Cookie=chocolate, ch.p
|
||||
----
|
||||
@@ -134,7 +134,7 @@ spring:
|
||||
gateway:
|
||||
routes:
|
||||
- id: header_route
|
||||
uri: http://example.org
|
||||
uri: https://example.org
|
||||
predicates:
|
||||
- Header=X-Request-Id, \d+
|
||||
----
|
||||
@@ -152,7 +152,7 @@ spring:
|
||||
gateway:
|
||||
routes:
|
||||
- id: host_route
|
||||
uri: http://example.org
|
||||
uri: https://example.org
|
||||
predicates:
|
||||
- Host=**.somehost.org,**.anotherhost.org
|
||||
----
|
||||
@@ -175,7 +175,7 @@ spring:
|
||||
gateway:
|
||||
routes:
|
||||
- id: method_route
|
||||
uri: http://example.org
|
||||
uri: https://example.org
|
||||
predicates:
|
||||
- Method=GET
|
||||
----
|
||||
@@ -193,7 +193,7 @@ spring:
|
||||
gateway:
|
||||
routes:
|
||||
- id: host_route
|
||||
uri: http://example.org
|
||||
uri: https://example.org
|
||||
predicates:
|
||||
- Path=/foo/{segment},/bar/{segment}
|
||||
----
|
||||
@@ -222,7 +222,7 @@ spring:
|
||||
gateway:
|
||||
routes:
|
||||
- id: query_route
|
||||
uri: http://example.org
|
||||
uri: https://example.org
|
||||
predicates:
|
||||
- Query=baz
|
||||
----
|
||||
@@ -237,7 +237,7 @@ spring:
|
||||
gateway:
|
||||
routes:
|
||||
- id: query_route
|
||||
uri: http://example.org
|
||||
uri: https://example.org
|
||||
predicates:
|
||||
- Query=foo, ba.
|
||||
----
|
||||
@@ -256,7 +256,7 @@ spring:
|
||||
gateway:
|
||||
routes:
|
||||
- id: remoteaddr_route
|
||||
uri: http://example.org
|
||||
uri: https://example.org
|
||||
predicates:
|
||||
- RemoteAddr=192.168.1.1/24
|
||||
----
|
||||
@@ -334,7 +334,7 @@ spring:
|
||||
gateway:
|
||||
routes:
|
||||
- id: add_request_header_route
|
||||
uri: http://example.org
|
||||
uri: https://example.org
|
||||
filters:
|
||||
- AddRequestHeader=X-Request-Foo, Bar
|
||||
----
|
||||
@@ -352,7 +352,7 @@ spring:
|
||||
gateway:
|
||||
routes:
|
||||
- id: add_request_parameter_route
|
||||
uri: http://example.org
|
||||
uri: https://example.org
|
||||
filters:
|
||||
- AddRequestParameter=foo, bar
|
||||
----
|
||||
@@ -370,7 +370,7 @@ spring:
|
||||
gateway:
|
||||
routes:
|
||||
- id: add_response_header_route
|
||||
uri: http://example.org
|
||||
uri: https://example.org
|
||||
filters:
|
||||
- AddResponseHeader=X-Response-Foo, Bar
|
||||
----
|
||||
@@ -388,7 +388,7 @@ spring:
|
||||
gateway:
|
||||
routes:
|
||||
- id: dedupe_response_header_route
|
||||
uri: http://example.org
|
||||
uri: https://example.org
|
||||
filters:
|
||||
- DedupeResponseHeader=Access-Control-Allow-Credentials Access-Control-Allow-Origin
|
||||
----
|
||||
@@ -402,7 +402,7 @@ The DedupeResponseHeader filter also accepts an optional `strategy` parameter. T
|
||||
https://github.com/Netflix/Hystrix[Hystrix] is a library from Netflix that implements the https://martinfowler.com/bliki/CircuitBreaker.html[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 http://cloud.spring.io/spring-cloud-netflix/[Spring Cloud Netflix].
|
||||
To enable Hystrix GatewayFilters in your project, add a dependency on `spring-cloud-starter-netflix-hystrix` from https://cloud.spring.io/spring-cloud-netflix/[Spring Cloud Netflix].
|
||||
|
||||
The Hystrix GatewayFilter Factory requires a single `name` parameter, which is the name of the `HystrixCommand`.
|
||||
|
||||
@@ -414,7 +414,7 @@ spring:
|
||||
gateway:
|
||||
routes:
|
||||
- id: hystrix_route
|
||||
uri: http://example.org
|
||||
uri: https://example.org
|
||||
filters:
|
||||
- Hystrix=myCommandName
|
||||
----
|
||||
@@ -545,7 +545,7 @@ spring:
|
||||
gateway:
|
||||
routes:
|
||||
- id: prefixpath_route
|
||||
uri: http://example.org
|
||||
uri: https://example.org
|
||||
filters:
|
||||
- PrefixPath=/mypath
|
||||
----
|
||||
@@ -563,7 +563,7 @@ spring:
|
||||
gateway:
|
||||
routes:
|
||||
- id: preserve_host_route
|
||||
uri: http://example.org
|
||||
uri: https://example.org
|
||||
filters:
|
||||
- PreserveHostHeader
|
||||
----
|
||||
@@ -618,7 +618,7 @@ spring:
|
||||
gateway:
|
||||
routes:
|
||||
- id: requestratelimiter_route
|
||||
uri: http://example.org
|
||||
uri: https://example.org
|
||||
filters:
|
||||
- name: RequestRateLimiter
|
||||
args:
|
||||
@@ -648,7 +648,7 @@ spring:
|
||||
gateway:
|
||||
routes:
|
||||
- id: requestratelimiter_route
|
||||
uri: http://example.org
|
||||
uri: https://example.org
|
||||
filters:
|
||||
- name: RequestRateLimiter
|
||||
args:
|
||||
@@ -668,12 +668,12 @@ spring:
|
||||
gateway:
|
||||
routes:
|
||||
- id: prefixpath_route
|
||||
uri: http://example.org
|
||||
uri: https://example.org
|
||||
filters:
|
||||
- RedirectTo=302, http://acme.org
|
||||
- RedirectTo=302, https://acme.org
|
||||
----
|
||||
|
||||
This will send a status 302 with a `Location:http://acme.org` header to perform a redirect.
|
||||
This will send a status 302 with a `Location:https://acme.org` header to perform a redirect.
|
||||
|
||||
=== RemoveHopByHopHeadersFilter GatewayFilter Factory
|
||||
The RemoveHopByHopHeadersFilter GatewayFilter Factory removes headers from forwarded requests. The default list of headers that is removed comes from the https://tools.ietf.org/html/draft-ietf-httpbis-p1-messaging-14#section-7.1.3[IETF].
|
||||
@@ -701,7 +701,7 @@ spring:
|
||||
gateway:
|
||||
routes:
|
||||
- id: removerequestheader_route
|
||||
uri: http://example.org
|
||||
uri: https://example.org
|
||||
filters:
|
||||
- RemoveRequestHeader=X-Request-Foo
|
||||
----
|
||||
@@ -719,7 +719,7 @@ spring:
|
||||
gateway:
|
||||
routes:
|
||||
- id: removeresponseheader_route
|
||||
uri: http://example.org
|
||||
uri: https://example.org
|
||||
filters:
|
||||
- RemoveResponseHeader=X-Response-Foo
|
||||
----
|
||||
@@ -741,7 +741,7 @@ spring:
|
||||
gateway:
|
||||
routes:
|
||||
- id: rewritepath_route
|
||||
uri: http://example.org
|
||||
uri: https://example.org
|
||||
predicates:
|
||||
- Path=/foo/**
|
||||
filters:
|
||||
@@ -761,7 +761,7 @@ spring:
|
||||
gateway:
|
||||
routes:
|
||||
- id: rewriteresponseheader_route
|
||||
uri: http://example.org
|
||||
uri: https://example.org
|
||||
filters:
|
||||
- RewriteResponseHeader=X-Response-Foo, , password=[^&]+, password=***
|
||||
----
|
||||
@@ -770,7 +770,7 @@ For a header value of `/42?user=ford&password=omg!what&flag=true`, it will be se
|
||||
|
||||
=== 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 http://projects.spring.io/spring-session/[Spring Session] with a lazy data store and need to ensure the session state has been saved before making the forwarded call.
|
||||
using something like https://projects.spring.io/spring-session/[Spring Session] with a lazy data store and need to ensure the session state has been saved before making the forwarded call.
|
||||
|
||||
.application.yml
|
||||
[source,yaml]
|
||||
@@ -780,14 +780,14 @@ spring:
|
||||
gateway:
|
||||
routes:
|
||||
- id: save_session
|
||||
uri: http://example.org
|
||||
uri: https://example.org
|
||||
predicates:
|
||||
- Path=/foo/**
|
||||
filters:
|
||||
- SaveSession
|
||||
----
|
||||
|
||||
If you are integrating http://projects.spring.io/spring-security/[Spring Security] with Spring Session, and want to ensure security details have been forwarded to the remote process, this is critical.
|
||||
If you are integrating https://projects.spring.io/spring-security/[Spring Security] with Spring Session, and want to ensure security details have been forwarded to the remote process, this is critical.
|
||||
|
||||
=== SecureHeaders GatewayFilter Factory
|
||||
The SecureHeaders GatewayFilter Factory adds a number of headers to the response at the reccomendation from https://blog.appcanary.com/2017/http-security-headers.html[this blog post].
|
||||
@@ -826,7 +826,7 @@ spring:
|
||||
gateway:
|
||||
routes:
|
||||
- id: setpath_route
|
||||
uri: http://example.org
|
||||
uri: https://example.org
|
||||
predicates:
|
||||
- Path=/foo/{segment}
|
||||
filters:
|
||||
@@ -846,7 +846,7 @@ spring:
|
||||
gateway:
|
||||
routes:
|
||||
- id: setresponseheader_route
|
||||
uri: http://example.org
|
||||
uri: https://example.org
|
||||
filters:
|
||||
- SetResponseHeader=X-Response-Foo, Bar
|
||||
----
|
||||
@@ -864,11 +864,11 @@ spring:
|
||||
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
|
||||
----
|
||||
@@ -886,14 +886,14 @@ spring:
|
||||
gateway:
|
||||
routes:
|
||||
- id: nameRoot
|
||||
uri: http://nameservice
|
||||
uri: https://nameservice
|
||||
predicates:
|
||||
- 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`.
|
||||
When a request is made through the gateway to `/name/bar/foo` the request made to `nameservice` will look like `https://nameservice/foo`.
|
||||
|
||||
=== Retry GatewayFilter Factory
|
||||
The Retry GatewayFilter Factory takes `retries`, `statuses`, `methods`, and `series` as parameters.
|
||||
@@ -1258,13 +1258,13 @@ spring:
|
||||
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
|
||||
----
|
||||
@@ -1378,7 +1378,7 @@ spring:
|
||||
globalcors:
|
||||
corsConfigurations:
|
||||
'[/**]':
|
||||
allowedOrigins: "http://docs.spring.io"
|
||||
allowedOrigins: "https://docs.spring.io"
|
||||
allowedMethods:
|
||||
- GET
|
||||
----
|
||||
@@ -1490,7 +1490,7 @@ To retrieve information about a single route, make a `GET` request to `/actuator
|
||||
"args": {"_genkey_0":"/first"}
|
||||
}],
|
||||
"filters": [],
|
||||
"uri": "http://www.uri-destination.org",
|
||||
"uri": "https://www.uri-destination.org",
|
||||
"order": 0
|
||||
}]
|
||||
----
|
||||
|
||||
Reference in New Issue
Block a user