From 5a70dc3b23ca7464e9fa81dbf4a9ea8cfb1237a0 Mon Sep 17 00:00:00 2001
From: Dave Syer 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 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. This feature is useful
+for a user interface to proxy to the backend services it requires,
+avoiding the need to manage CORS and authentication concerns
+independently for all the backends. To augment or change the proxy routes, you can add external
-configuration like the following: To enable it, annotate a Spring Boot main class with
+ To skip having a service automatically added, set
+ This means that http calls to "/myusers" get forwarded to the "users"
-service. This configuration is useful for a user interface to proxy to
-the backend services it requires (avoiding the need to manage CORS and
-authentication concerns independently for all the backends). To get more fine-grained control over a route you can specify the path
@@ -2140,10 +2155,11 @@ level, but "/myusers/*" matches hierarchically. Forwarding to the service is protected by a Hystrix circuit breaker so if a service is down the client will see an error, but once the circuit is open the proxy will not try to contact the service. To add a prefix to all mappings, set To add a prefix to all mappings, set In this example requests to "/myusers/101" will be forwarded to "/101" on the "users" service (the path is stripped up to the first wildcard character). In this example requests to "/myusers/101" will be forwarded to "/myusers/101" on the "users" service. The The An application with the An application with the Embedded Zuul Reverse Proxy
@EnableZuulProxy, and this forwards local calls to the appropriate service. By convention, a service with the Eureka ID "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.@EnableZuulProxy, and this forwards local calls to the appropriate
+service. By convention, a service with the Eureka ID "users", will
+receive requests from the proxy located at /users (with the prefix
+stripped). The proxy uses Ribbon to locate an instance to forward to
+via Eureka, and all requests are executed in a hystrix command, so
+failures will show up in Hystrix metrics, and once the circuit is open
+the proxy will not try to contact the service.zuul.ignored-services to a list of service ids. To augment or change
+the proxy routes, you can add external configuration like the
+following:zuul.prefix to a value, such as /api. To strip the proxy prefix from the request before the request is forwarded set zuul.stripPrefix = true. You can also strip the non-wildcard prefix from individual routes, e.g.zuul.prefix to a value, such as
+/api. The proxy prefix is stripped from the request before the
+request is forwarded by default (switch this behaviour off with
+zuul.stripPrefix=false). You can also switch off the stripping of
+the service-specific prefix from individual routes, e.g.X-Forwarded-Host header added to the forwarded requests by default. To turn it off set zuul.addProxyHeaders = false.X-Forwarded-Host header added to the forwarded requests by
+default. To turn it off set zuul.addProxyHeaders = false. The
+prefix path is stripped by default, and the request to the backend
+picks up a header "X-Forwarded-Prefix" ("/myusers" in the examples
+above).@EnableZuulProxy could act as a standalone server if you set a default route ("/"), for example zuul.route.home: / would route all traffic (i.e. "/**") to the "home" service.@EnableZuulProxy could act as a standalone
+server if you set a default route ("/"), for example zuul.route.home:
+/ would route all traffic (i.e. "/**") to the "home" service.