原创

网关代理插件zuul的使用

springcloud网关zuul

1、引入pom

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-zuul</artifactId>
    <version>1.4.0.RELEASE</version>
    <exclusions>
        <exclusion>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-logging</artifactId>
        </exclusion>
    </exclusions>
</dependency>

2、开启配置

@EnableZuulProxy // 开启网关功能
public class Application {
}

3、自定义配置规则

zuul.routes.products.path = /**
zuul.routes.products.url = xxxx
zuul.ignored-patterns = /**/notice/**,/doc.html,/swagger-resources,/v2/api-docs,/**/webjars/**,/**/health,/**/shutdown,/**/eurekaRegistration/stop,/**/mappings
  • zuul.routes.products.path 表示拦截的url,/**表示拦截所有的请求,多个url可以用,分隔
  • zuul.routes.products.url表示转发的服务目标地址
  • zuul.ignored-patterns 表示的需要特殊排除的url,多个url用,分隔
正文到此结束
本文目录