Spring Cloud之Zuul网关集群
Nginx+Zuul 一主一备 或者 轮训多个
在微服务中,所有服务请求都会统一到Zuul网关上。

Nginx 配置:
#user nobody;
worker_processes 1; #error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info; #pid logs/nginx.pid; events {
worker_connections 1024;
} http {
include mime.types;
default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on;
#tcp_nopush on; #keepalive_timeout 0;
keepalive_timeout 65; #gzip on; upstream backServer{
server 192.168.8.159:81;
server 192.168.8.159:82;
} server {
listen 80;
server_name www.toov5.com; location / { ### 指定上游服务器负载均衡服务器
proxy_pass http://backServer/;
index index.html index.htm; }
} }
网关:
yml:
###注册 中心
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8100/eureka/
server: ##api网关端口号
port: 81
###网关名称
spring: ##网关服务名称
application:
name: service-zuul
###网关名称
cloud:
config:
####读取后缀
profile: dev
####读取config-server注册地址
discovery:
service-id: confi ### 配置网关反向代理
zuul:
routes:
api-member: ##随便写的
### 以 /api-member/访问转发到会员服务 通过别名找
path: /api-member/**
serviceId: app-toov5-member ##别名 如果集群的话 默认整合了ribbon 实现轮训 负载均衡
api-order: ##随便写的
### 以 /api-order/访问转发到订单服务
path: /api-order/**
serviceId: app-toov5-order ##别名
启动类:
package com.toov5; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.zuul.EnableZuulProxy; @SpringBootApplication
@EnableEurekaClient
@EnableZuulProxy //开启网关代理
public class AppGateway {
public static void main(String[] args) {
SpringApplication.run(AppGateway.class, args);
}
// //zuul配置使用config实现实时更新
// @RefreshScope
// @ConfigurationProperties("zuul")
// public ZuulProperties zuulProperties() {
// return new ZuulProperties();
// } }
访问:

启动两个网关 81和82


Spring Cloud之Zuul网关集群的更多相关文章
- spring cloud 通过zuul网关去请求的时候报404的几个原因。
spring cloud 中 zuul 网关的那些坑: 1.检查你的服务是否正常启动. 2.检查你的服务是否正常注册到注册中心. 3.zuul网关的路由规则是会把你注册在注册中心的serviceId ...
- Spring Cloud(Dalston.SR5)--Config 集群配置中心
Spring Cloud Config 是一个全新的项目,用来为分布式系统中的基础设施和微服务应用提供集中化的外部配置支持,他分为服务端和客户端两个部分.服务端也称为分布式配置中心,是一个独立的微服务 ...
- Spring Cloud Eureka 注册中心集群搭建,Greenwich 最新版!
Spring Cloud 的注册中心可以由 Eureka.Consul.Zookeeper.ETCD 等来实现,这里推荐使用 Spring Cloud Eureka 来实现注册中心,它基于 Netfl ...
- Spring Cloud Turbine微服务集群实时监控
本文代码下载地址: https://gitlab.com/mySpringCloud/turbine SpringBoot版本:1.5.9.RELEASE (稳定版) SpringCloud版本:Ed ...
- Spring Cloud系列-Zuul网关集成JWT身份验证
前言 这两三年项目中一直在使用比较流行的spring cloud框架,也算有一定积累,打算有时间就整理一些干货与大家分享. 本次分享zuul网关集成jwt身份验证 业务背景 项目开发少不了身份认证,j ...
- Spring Cloud之Zuul网关路由
前端请求先通过nginx走到zuul网关服务,zuul负责路由转发.请求过滤等网关接入层的功能,默认和ribbon整合实现了负载均衡 比如说你有20个服务,暴露出去,你的调用方,如果要跟20个服务打交 ...
- SpringCLoud之搭建Zuul网关集群
1.使用技术 Springboot,SpringCloud,Zuul,Nignx 2.目的 使用Zuul搭建微服务高可用的网关 3.项目创建 3.1 创建注册中心(略) 3.2 创建一个hello-s ...
- Spring Cloud项目之断路器集群监控Hystrix Dashboard
微服务(Microservices Architecture)是一种架构风格,一个大型复杂软件应用由一个或多个微服务组成.系统中的各个微服务可被独立部署,各个微服务之间是松耦合的.每个微服务仅关注于完 ...
- 【spring cloud】spring cloud中启动eureka集群时候,发生端口已经绑定的报错The Tomcat connector configured to listen on port 8000 failed to start. The port may already be in use or the connector may be misconfigured.
在分别设置 进行微服务eureka集群启动时候,执行命令行启动jar包时候,报错前面一个端口8000已经被使用,而我这里启动的配置文件中端口号是8001,怎么会导致端口冲突呢?? 但是报错我的端口冲突 ...
随机推荐
- nginx 直接返回状态码
server { listen 80; server_name service.aaa.com; location / { add_header Content-Type "text/pla ...
- stage3D基础五-----Working with 3D cameras(转)
原文地址:http://www.adobe.com/cn/devnet/flashplayer/articles/3d-cameras.html 原文是英文的,这里就不贴了,内容主要介绍直接使用相机坐 ...
- ubuntu16.04上安装深度学习基本框架caffe2 pytorch tensorflow opencv
anaconda3.5.2.0----python3.6: conda install tensorflow-gpu -y --prefix /media/wkr/diskHgst/ubun ...
- html中keydown事件
实现在输入框按回车按钮进行查询的功能: 1.<input type="text" id="inputChannel" onkeydown="ke ...
- OpenOffice/LibreOffice的行距问题
OpenOffice和LibreOffice的默认行距(行间距)都很宽,可以通过以下方法设置. 格式 -> 页面 -> 文字网格 -> 不使用网格
- Sql效能优化总结(续)- sql语句优化篇
今晚继续进行Sql效能问题的分享,今天主要是一些具体的sql优化方法和思路分享,若看过后你也有其他想法,欢迎一起探讨,好了,进入今天的主题. 针对性地对一些耗资源严重的具体应用进行优化 出现效能问题时 ...
- hdu2767之强联通缩点
Proving Equivalences Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Oth ...
- MySql 数据库系列问题
0. 我的MYSQL学习心得(四) 数据类型(系列文章) 1.MySql数据库学习--存储过程(1) 0.[转]MySQL存储过程调试工具-dbForge Studio for MySQL ①.存储过 ...
- erlang的斐波那契数列
[递归和循环] 题目: 大家都知道斐波那契数列,现在要求输入一个整数N,请输出斐波那契数列的第N项,以及前N项. 如:N <=39 下面是斐波那契数列的实现: -module(feibo). - ...
- php跨域共享session
. $gb_DBHOSTname = "127.0.0.1"; //主机的名称或是IP地址 02 $gb_DBname = "dbname"; //数据库名称 ...