From e4da089a878f026d683e95dd37d8146092a645f7 Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Sat, 29 Nov 2014 12:09:57 +0000 Subject: [PATCH] Sync docs from master to gh-pages --- spring-cloud.html | 43 +++++++++---------------------------------- 1 file changed, 9 insertions(+), 34 deletions(-) diff --git a/spring-cloud.html b/spring-cloud.html index 3fe5d19..689068b 100644 --- a/spring-cloud.html +++ b/spring-cloud.html @@ -480,7 +480,6 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
  • Router and Filter: Zuul
  • @@ -650,7 +649,7 @@ Boot application that depends on spring-cloud-config-client (e.g. see the test cases for the config-client, or the sample app). The most convenient way to add the dependency is via a Spring Boot starter org.springframework.cloud:spring-cloud-starter. There is also a -parent pom and BOM (spring-cloud-starters) for Maven users and a +parent pom and BOM (spring-cloud-starter-parent) for Maven users and a Spring IO version management properties file for Gradle and Spring CLI users. Example Maven configuration:

    @@ -668,7 +667,7 @@ users. Example Maven configuration:

    <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> - <artifactId>spring-cloud-starters</artifactId> + <artifactId>spring-cloud-starter-parent</artifactId> <version>1.0.0.BUILD-SNAPSHOT</version> <type>pom</type> <scope>import</scope> @@ -2067,48 +2066,24 @@ public class Application extends FeignConfigurer {

    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.

    -
    -
    -
    -

    Standalone Zuul Server

    -
    -

    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
    -
    +

    The Zuul proxy supports Ant-style patterns.

    -

    This means that http calls to /users get forwarded to the users service.

    +

    The X-Forwarded-Host header added to the forwarded requests by default. To turn it off set zuul.proxy.add-proxy-headers = false.

    -

    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.

    @@ -2653,7 +2628,7 @@ service or the "resource" service if you have one).