SpringCloud Gateway: Gateway

A gateway is an intermediate layer interposed between the client and server side, all external requests through the gateway that will first layer. In other words, implementing aspects of the API more on business logic and security, performance, monitoring can be handed over to the gateway to do, both to increase business agility not lack of security, the typical architecture is shown in Figure:

 

 

  • Safety, only the gateway system in foreign exposure, including micro-network services can be hidden by firewall protection.

  • Easy to monitor. Monitoring data can be collected and push them to the external gateway system for analysis.

  • Easy to certification. Certification can be performed on the gateway, and then forwards the request to the backend of micro-services, without having to authenticate each micro service.

  • It reduces the number of interactions between the client and the various micro-services

  • Ease of unified authentication.

Application Notes are as follows:

@EnableZuulProxy
@SpringCloudApplication
public class ZuulGatewayApplication {
    public static void main(String[] args) {
        SpringApplication.run(ZuulGatewayApplication.class,args);
    }
}

yaml configuration file as follows:

Server: 
  Port: 9000 
the Spring: 
  the Application: 
    name: AD - Gateway 
Eureka: 
  Client: 
    Service - url: 
      defaultzone: HTTP: // server1: 8000 / Eureka / 

# gateway configuration 
Zuul: 
  prefix: / ZMN # unified prefix 
  routes: # route 
    path: / ad-sponsor / ** # prefix 
    serviceId: eureka-client-ad- sponsor # micro-forwarding service names 
    strip-prefix: false # Do not skip the prefix / ad-sponsor
                         

 

 

Guess you like

Origin www.cnblogs.com/zhuomuniao/p/12391957.html