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,怎么会导致端口冲突呢?? 但是报错我的端口冲突 ...
随机推荐
- 不可忽略的apache 的 Keep Alive
转载链接:http://hi.baidu.com/jx_iben/item/d5fe91feed74495ec9f337f1 在网页开发过程中,Keep-Alive是HTTP协议中非常重要的一个属性. ...
- jenkins和gitlab版本
- python学习 05 函数switch功能
1.python没有switch功能,利用字典实现 如果用if else,可行但是效率不高
- 关于移动端border 1像素在不同分辨率下边显示粗细不一样的处理
最近开发发现一个很有趣的问题 就是我如果给一个元素加上一个像素的 border 在不同的分辨率的情况下显示的不同 在高清屏幕(尤其是ios 喽 不鄙视国产) 据说在6plus下会变成3px 这个我 ...
- 写shader注意的一些报错
1.Shader warning in 'Custom/1': Both vertex and fragment programs must be present in a CGPROGRAM. Ex ...
- Lumen开发:结合Redis实现消息队列(1)
1.简介 Lumen队列服务为各种不同的后台队列提供了统一的API.队列允许你推迟耗时任务(例如发送邮件)的执行,从而大幅提高web请求速度. 1.1 配置 .env文件的QUEUE_DRIVER选项 ...
- linux下apache php配置redis
1.安装redis 第一步: 下载:https://github.com/nicolasff/phpredis/archive/2.2.4.tar.gz 上传phpredis-2.2.4.tar.gz ...
- python 之前函数补充(__del__, item系列, __hash__, __eq__) , 以及模块初体验
__str__ : str(obj) , 需求必须实现了 __str__, 要求这个方法的返回值必须是字符串 str 类型 __repr__ (意为原型输出): 是 __str__ 的备胎( ...
- hdu3579(线性同余方程组)
Hello Kiki Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total ...
- Spring框架结构
在processOn思维导图上看的一个程序员写的,挺不错的,分享出来,便于学习和回顾.