Only, without much technical content, the right to remember this memo.
Zuul
what: micro gateway service, the equivalent of a reverse proxy server (this time with Nginx, Spring Cloud Gateway functionality is similar). Here record Spring Cloud integrated Zuul, Consul of use.
how it works:
The introduction of dependent (here registered service components with consul):
<dependency> <the groupId> org.springframework.cloud </ the groupId> <the artifactId> Starter-Spring-Cloud-Consul-Discovery </ the artifactId> </ dependency> <-! dependent as a self-contained spring boot starter web, actuator other dependent, dependent as it is a primer SpringBoot the project -> <dependency> <the groupId> org.springframework.cloud </ the groupId> <the artifactId> Starter-Spring-Cloud-Zuul </ the artifactId> <Version> 1.4.7 .RELEASE </ Version> </ dependency>
Main categories:
@SpringBootApplication @EnableZuulProxy public class ZuulMain { public static void main(String[] args) { SpringApplication.run(ZuulMain.class, args); } }
Configuration:
server: port: 8084 spring: application: name: sensestudy-zuul cloud: consul: enabled: true host: localhost port: 8500 discovery: # serviceName: ${spring.application.name} tags: sensestudy, zuul healthCheckInterval: 15s fail-fast: false prefer-ip-address: true # health-check-path: ${server.servlet.context-path}/actuator/health zuul: # prefix: /sensestudy # path unified prefix ignored -services: '*' # default routing rules for the press service id to find the target address of the service, this configuration disables the default behavior, configure routing rules routes by the following routes: sensestudy - ACL: / ACL / ** App1: path: / coursecenter / ** the serviceId: sensestudy-coursecenter # URL: http://www.baidu.com
Description:
Default routing rules: for http: // localhost:? 8080 / sensestudy / myacl userId = 1, zuul it will try to initiate a request from a service registry to find the id myacl service. Disable the default rule is usually ignored-services by their own rules and specify the route.
Custom routing rules:
ACL-sensestudy: / ACL / ** : Zuul will match a request in which the specified path, and forwarded to the service id of the former. This is the most shorthand, as shown above, it can also be arranged in a plurality of rows with both the specified correspondence relationship.
References:
https://github.com/Netflix/zuul/wiki
https://www.cnblogs.com/leeSmall/p/8850215.html