Skip to content

3.2 ZuulProxy Config

Fanyuepan edited this page Mar 10, 2019 · 5 revisions

自定义路由名称,如果不想使用 GATEWAY-SERVER/SERVICE-ID/**的方式访问微服务,可以定义路由名称,例如


zuul:
  routes:
    account:
      path: /account/**
      serviceId: fly-account-service
      # 使用前缀
      stripPrefix: true

以下两个地址均能正常访问

  • http://localhost:9001/account/account/testZuul
  • http://localhost:9001/fly-account-service/account/testZuul

filters 端点,访问 http://localhost:9001/actuator/filters

{
	"error": [{
		"class": "org.springframework.cloud.netflix.zuul.filters.post.SendErrorFilter",
		"order": 0,
		"disabled": false,
		"static": true
	}],
	"post": [{
		"class": "org.springframework.cloud.netflix.zuul.filters.post.SendResponseFilter",
		"order": 1000,
		"disabled": false,
		"static": true
	}],
	"pre": [{
		"class": "org.springframework.cloud.netflix.zuul.filters.pre.DebugFilter",
		"order": 1,
		"disabled": false,
		"static": true
	}, {
		"class": "org.springframework.cloud.netflix.zuul.filters.pre.FormBodyWrapperFilter",
		"order": -1,
		"disabled": false,
		"static": true
	}, {
		"class": "org.springframework.cloud.netflix.zuul.filters.pre.Servlet30WrapperFilter",
		"order": -2,
		"disabled": false,
		"static": true
	}, {
		"class": "org.springframework.cloud.netflix.zuul.filters.pre.ServletDetectionFilter",
		"order": -3,
		"disabled": false,
		"static": true
	}, {
		"class": "org.springframework.cloud.netflix.zuul.filters.pre.PreDecorationFilter",
		"order": 5,
		"disabled": false,
		"static": true
	}],
	"route": [{
		"class": "org.springframework.cloud.netflix.zuul.filters.route.SimpleHostRoutingFilter",
		"order": 100,
		"disabled": false,
		"static": true
	}, {
		"class": "org.springframework.cloud.netflix.zuul.filters.route.RibbonRoutingFilter",
		"order": 10,
		"disabled": false,
		"static": true
	}, {
		"class": "org.springframework.cloud.netflix.zuul.filters.route.SendForwardFilter",
		"order": 500,
		"disabled": false,
		"static": true
	}]
}

忽略指定服务

 # 忽略指定服务,如果要忽略所有, 使用 *
 ignored-services: fly-config-server,eureka-server

路径匹配

zuul:
  routes:
    account:
      path: /account/**
      serviceId: fly-account-service