前面已经搭建好了一个最基础的Spring Cloud框架,最后,整个Spring Cloud的注册服务如下:
其中,DISCOVERY-SERVICE是两个Eureka服务;CONFIG-SERVER-SERVICE是配置中心服务器;HELLO-SERVICE是实际业务;FEIGN-SERVICE是服务负载和服务容错;GATE-SERVICE是服务路由。
总线服务已经集成在config-client(包括HELLO-SERVICE、FEIGN-SERVICE、GATE-SERVICE),这些服务都可以动态修改配置。
最后在通过Nginx对gate-service进行负载均衡,Nginx简单配置如下:
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
upstream 172.23.27.84 {
server 172.23.27.84:9001;
server 172.23.27.84:9002;
}
server {
listen 10080;
server_name 172.23.27.84;
location / {
root html;
index index.html index.htm;
proxy_pass http://172.23.27.84;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
整个服务可以通过入口http://172.23.27.84:10080/find/hello?accessToken=admin来访问。
架构图如下:
对外开放的服务是gate-service,其他服务仅对内部开放。