Sync docs from master to gh-pages
This commit is contained in:
@@ -2085,11 +2085,28 @@ public class Application extends FeignConfigurer {
|
|||||||
<div class="sect2">
|
<div class="sect2">
|
||||||
<h3 id="netflix-zuul-reverse-proxy">Embedded Zuul Reverse Proxy</h3>
|
<h3 id="netflix-zuul-reverse-proxy">Embedded Zuul Reverse Proxy</h3>
|
||||||
<div class="paragraph">
|
<div class="paragraph">
|
||||||
<p>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 <code>@EnableZuulProxy</code>, 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 <code>/users</code>. The proxy uses Ribbon to locate an instance to forward to via Eureka. To skip having a service automatically added from eureka, set <code>zuul.ignored-services = service1</code>.</p>
|
<p>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.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="paragraph">
|
<div class="paragraph">
|
||||||
<p>To augment or change the proxy routes, you can add external
|
<p>To enable it, annotate a Spring Boot main class with
|
||||||
configuration like the following:</p>
|
<code>@EnableZuulProxy</code>, 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 <code>/users</code> (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.</p>
|
||||||
|
</div>
|
||||||
|
<div class="paragraph">
|
||||||
|
<p>To skip having a service automatically added, set
|
||||||
|
<code>zuul.ignored-services</code> to a list of service ids. To augment or change
|
||||||
|
the proxy routes, you can add external configuration like the
|
||||||
|
following:</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="listingblock">
|
<div class="listingblock">
|
||||||
<div class="title">application.yml</div>
|
<div class="title">application.yml</div>
|
||||||
@@ -2101,9 +2118,7 @@ configuration like the following:</p>
|
|||||||
</div>
|
</div>
|
||||||
<div class="paragraph">
|
<div class="paragraph">
|
||||||
<p>This means that http calls to "/myusers" get forwarded to the "users"
|
<p>This means that http calls to "/myusers" get forwarded to the "users"
|
||||||
service. This configuration is useful for a user interface to proxy to
|
service (for example "/myusers/101" is forwarded to "/101").</p>
|
||||||
the backend services it requires (avoiding the need to manage CORS and
|
|
||||||
authentication concerns independently for all the backends).</p>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="paragraph">
|
<div class="paragraph">
|
||||||
<p>To get more fine-grained control over a route you can specify the path
|
<p>To get more fine-grained control over a route you can specify the path
|
||||||
@@ -2140,10 +2155,11 @@ level, but "/myusers/</strong>*" matches hierarchically.</p>
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="paragraph">
|
<div class="paragraph">
|
||||||
<p>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.</p>
|
<p>To add a prefix to all mappings, set <code>zuul.prefix</code> to a value, such as
|
||||||
</div>
|
<code>/api</code>. The proxy prefix is stripped from the request before the
|
||||||
<div class="paragraph">
|
request is forwarded by default (switch this behaviour off with
|
||||||
<p>To add a prefix to all mappings, set <code>zuul.prefix</code> to a value, such as <code>/api</code>. To strip the proxy prefix from the request before the request is forwarded set <code>zuul.stripPrefix = true</code>. You can also strip the non-wildcard prefix from individual routes, e.g.</p>
|
<code>zuul.stripPrefix=false</code>). You can also switch off the stripping of
|
||||||
|
the service-specific prefix from individual routes, e.g.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="listingblock">
|
<div class="listingblock">
|
||||||
<div class="title">application.yml</div>
|
<div class="title">application.yml</div>
|
||||||
@@ -2152,17 +2168,23 @@ level, but "/myusers/</strong>*" matches hierarchically.</p>
|
|||||||
routes:
|
routes:
|
||||||
users:
|
users:
|
||||||
path: /myusers/**
|
path: /myusers/**
|
||||||
stripPrefix: true</code></pre>
|
stripPrefix: false</code></pre>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="paragraph">
|
<div class="paragraph">
|
||||||
<p>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).</p>
|
<p>In this example requests to "/myusers/101" will be forwarded to "/myusers/101" on the "users" service.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="paragraph">
|
<div class="paragraph">
|
||||||
<p>The <code>X-Forwarded-Host</code> header added to the forwarded requests by default. To turn it off set <code>zuul.addProxyHeaders = false</code>.</p>
|
<p>The <code>X-Forwarded-Host</code> header added to the forwarded requests by
|
||||||
|
default. To turn it off set <code>zuul.addProxyHeaders = false</code>. 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).</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="paragraph">
|
<div class="paragraph">
|
||||||
<p>An application with the <code>@EnableZuulProxy</code> could act as a standalone server if you set a default route ("/"), for example <code>zuul.route.home: /</code> would route all traffic (i.e. "/**") to the "home" service.</p>
|
<p>An application with the <code>@EnableZuulProxy</code> could act as a standalone
|
||||||
|
server if you set a default route ("/"), for example <code>zuul.route.home:
|
||||||
|
/</code> would route all traffic (i.e. "/**") to the "home" service.</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -2737,7 +2759,7 @@ service or the "resource" service if you have one).</p>
|
|||||||
</div>
|
</div>
|
||||||
<div id="footer">
|
<div id="footer">
|
||||||
<div id="footer-text">
|
<div id="footer-text">
|
||||||
Last updated 2014-12-04 10:06:36 UTC
|
Last updated 2014-12-04 12:05:41 UTC
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
Reference in New Issue
Block a user