change zuul implementation to be controller/handler mapping based.
This allows mappings to be at the root and not have to be prefixed. It also allows mappings to fall through to other handler mappings. Patterns are now Ant-style via AntPathMatcher. fixes gh-72
This commit is contained in:
@@ -500,33 +500,15 @@ Zuul's rule engine allows rules and filters to be written in essentially any JVM
|
||||
[[netflix-zuul-reverse-proxy]]
|
||||
=== Embedded Zuul Reverse Proxy
|
||||
|
||||
Spring Cloud has created an embedded Zuul proxy to ease the development of a very common use case where a UI application wants to proxy calls to one or more back end services. To enable it, annotate a Spring Boot main class with `@EnableZuulProxy`. This forwards local calls to `/proxy/*` to the appropriate service. The proxy uses Ribbon to locate an instance to forward to via Eureka. Forwarding to the service is protected by a Hystrix circuit breaker. Rules are configured via the Spring environment. The Config Server is an ideal place for the Zuul configuration. Zuul Embedded Proxy configuration rules look like the following:
|
||||
Spring Cloud has created an embedded Zuul proxy to ease the development of a very common use case where a UI application wants to proxy calls to one or more back end services. To enable it, annotate a Spring Boot main class with `@EnableZuulProxy`. This forwards local calls to the appropriate service. By convention, a service with the `spring.application.name` of `users`, will receive requests from the proxy located at `/users`. The proxy uses Ribbon to locate an instance to forward to via Eureka. To skip having a service automatically added from eureka, set `zuul.ignored-services = service1`. Forwarding to the service is protected by a Hystrix circuit breaker. Additional rules can be configured via the Spring environment. The Config Server is an ideal place for the Zuul configuration. Zuul Embedded Proxy configuration rules look like the following:
|
||||
|
||||
zuul.proxy.route.users: /users
|
||||
zuul.route.users: /myusers/**
|
||||
|
||||
This means that http calls to /proxy/users get forwarded to the users service. This proxy configuration is useful for services that host a user interface to proxy to the backend services it requires. To change the mapping, set `zuul.proxy.mapping` to a different value, such as `/api`. By default, the proxy mapping gets stripped from the request before forwarding. To keep the proxy mapping on the forwarded call, set `zuul.proxy.stripMapping = false`.
|
||||
This means that http calls to /myusers get forwarded to the users service. This proxy configuration is useful for services that host a user interface to proxy to the backend services it requires. To add a prefix to the mapping, set `zuul.proxy.mapping` to a value, such as `/api`. To strip the proxy mapping from the request before forwarding set `zuul.proxy.strip-mapping = true`.
|
||||
|
||||
To have the `X-Forwarded-Host` header added to the forwarded requests, set `zuul.proxy.addProxyHeaders = true`.
|
||||
The Zuul proxy supports Ant-style patterns.
|
||||
|
||||
[[netflix-zuul-server]]
|
||||
=== Standalone Zuul Server
|
||||
The `X-Forwarded-Host` header added to the forwarded requests by default. To turn it off set `zuul.proxy.add-proxy-headers = false`.
|
||||
|
||||
Spring Cloud has created a standalone Zuul server. To enable it, annotate a Spring Boot main class with `@EnableZuulServer`. This routes all calls to the appropriate service. The server uses Ribbon to locate an instance to forward to via Eureka. Forwarding to the service is protected by a Hystrix circuit breaker. Rules are configured via the Spring environment. The Config Server is an ideal place for the Zuul configuration. Zuul Server configuration rules look like the following:
|
||||
|
||||
zuul.server.route.users: /users
|
||||
|
||||
This means that http calls to /users get forwarded to the users service.
|
||||
|
||||
Since zuul, by default, intercepts all requests (`/*`), to enable actuator, you should set the `management.port`.
|
||||
|
||||
To use the Spring Boot error facilities while using the standalone Zuul server, please set the following properties
|
||||
|
||||
----
|
||||
# moves the Spring Dispatch Servlet to a path below `/`
|
||||
server:
|
||||
servletPath: /app
|
||||
# sets the error path to use the Dispatch Servlet to resolve the error view
|
||||
error:
|
||||
path: ${server.servletPath}/error
|
||||
----
|
||||
An application with the `@EnableZuulProxy` could act as a standalone server if you set a default route, for example `zuul.route.home: /` would route `/` to the home service.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user