当前位置: 首页 > news >正文

建网站平台要多少钱郑州网络营销推广机构

建网站平台要多少钱,郑州网络营销推广机构,百度网站提交入口,东营市建设信息网文章目录 1、灰度发布实现1.1 按随机用户的流量百分比实现灰度1.2 按人群划分实现的灰度1.2.1 通过Header信息实现灰度1.2.2 通过Query信息实现灰度1.2.3 通过RemoteAdd判断来源IP实现灰度 2、路由判断器2.1. After2.2. Before2.3. Between2.4. Cookie2.5. Header2.6. Host2.7.…

文章目录

    • 1、灰度发布实现
      • 1.1 按随机用户的流量百分比实现灰度
      • 1.2 按人群划分实现的灰度
        • 1.2.1 通过Header信息实现灰度
        • 1.2.2 通过Query信息实现灰度
        • 1.2.3 通过RemoteAdd判断来源IP实现灰度
    • 2、路由判断器
      • 2.1. After
      • 2.2. Before
      • 2.3. Between
      • 2.4. Cookie
      • 2.5. Header
      • 2.6. Host
      • 2.7. Method
      • 2.8. Path
      • 2.9. Query
      • 2.10. RemoteAddr
      • 2.11. Weight
      • 2.12. XForwarded Remote Addr

1、灰度发布实现

以前使用APISIX实现过灰度发布《jenkins与apisix整合,实现自动化部署与负载均衡、灰度发布(蓝绿发布)》
同样可以使用Spring Gateway实现类似灰度功能。本文使用前文的示例代码《Spring Cloud 2022.x版本使用gateway和nacos实现动态路由和负载均衡》来演示效果
app1和app2两个工程都增加一个version接口

示例代码如下:

// app1工程,版本1.0
private static int count = 0;
@GetMapping("/version")
public Map<String, Object> version(){Map<String, Object> data = new HashMap<>();data.put("visit_count", ++count);data.put("version", "1.0");data.put("service", "app1");return data;}
// app2工程,版本1.0
private static int count = 0;
@GetMapping("/version")
public Map<String, Object> version(){Map<String, Object> data = new HashMap<>();data.put("visit_count", ++count);data.put("version", "1.0");data.put("service", "app2");return data;}

正常负载均衡时nacos里gatewayapp.yml路由配置

- id: appuri: lb://app-servicepredicates:- Path=/app/**filters:- StripPrefix=1

访问10次,两个服务分别占50%流量。
在这里插入图片描述

1.1 按随机用户的流量百分比实现灰度

app2发布新版本,此时接口代码的版本号修改为1.1。
对访问的用户,随机分配流量,新版本流量占20%,旧版本流量占80%,使用Gateway的Weight路由判断器来实现。Nacos的路由配置修改为:

- id: app_grayuri: http://localhost:9092predicates:- Path=/app/**- Weight=group1, 20filters:- StripPrefix=1
- id: appuri: http://localhost:9091predicates:- Path=/app/**- Weight=group1, 80filters:- StripPrefix=1

在这里插入图片描述

1.2 按人群划分实现的灰度

按用户id、用户ip等方式实现的灰度,一般用户属性信息可以放在Header、Cookie、请求参数。可以通过路由判断器Cookie、Header、Query、RemoteAddr、XForwardedRemoteAddr判断属性值是否进入灰度环境

1.2.1 通过Header信息实现灰度

用户id<100访问,进入灰度新版本,其他用户进入旧版本,Nacos的路由配置修改为:

spring:cloud:gateway:routes:- id: app_grayuri: http://localhost:9092predicates:- Header=userid, ^([1-9][0-9]?)$- Path=/app/**filters:- StripPrefix=1- id: appuri: http://localhost:9091predicates:- Path=/app/**filters:- StripPrefix=1

在这里插入图片描述

1.2.2 通过Query信息实现灰度

用户id<100访问,进入灰度新版本,其他用户进入旧版本,Nacos的路由配置修改为:

spring:cloud:gateway:routes:- id: app_grayuri: http://localhost:9092predicates:- Query=userid, ^([1-9][0-9]?)$- Path=/app/**filters:- StripPrefix=1- id: appuri: http://localhost:9091predicates:- Path=/app/**filters:- StripPrefix=1

在这里插入图片描述

1.2.3 通过RemoteAdd判断来源IP实现灰度

只允许ip=192.168.76.128的访问,进入灰度新版本,其他用户进入旧版本,Nacos的路由配置修改为:

spring:cloud:gateway:routes:- id: app_grayuri: http://localhost:9092predicates:- RemoteAddr=192.168.76.128/24- Path=/app/**filters:- StripPrefix=1- id: appuri: http://localhost:9091predicates:- Path=/app/**filters:- StripPrefix=1

在这里插入图片描述

2、路由判断器

Spring Cloud Gateway包括许多内置的路由判断器,官方介绍https://docs.spring.io/spring-cloud-gateway/docs/current/reference/html/#gateway-request-predicates-factories

这些路由判断器匹配HTTP请求的不同属性。可以将多个路由判断器与逻辑和语句组合在一起。

名称说明
AfterAfter路由接受一个日期参数,匹配在指定日期时间之后发生的请求。
BeforeBefore路由接受一个日期参数,匹配在指定日期时间之前发生的请求。
BetweenBetween路由接受两个参数datetime1和datetime2,匹配在datetime1之后和datetime2之前发生的请求。
CookieCookie路由接受两个参数,Cookie名称和regexp(一个Java正则表达式),匹配具有给定名称且其值与正则表达式匹配的cookie。
HeaderHeader路由接受两个参数:Header名称和regexp(一个Java正则表达式),匹配与具有给定名称且其值与正则表达式匹配的hearder。
HostHost路由接受一个参数:域名列表,匹配列表中的域名地址。
MethodMethod路由接受一个Http方法(GET、POST…)参数,该参数是一个或多个HTTP方法。
PathPath路由判断器接受两个参数:Spring PathMatcher模式列表和一个名为matchTrailingSlash的可选标志(默认为true)。
QueryQuery路由器接受两个参数:一个必需的参数和一个可选的regexp(它是一个Java正则表达式)。
RemoteAddrRemoteAddr路由器接受一个来源列表(至少1个),这些来源地址是IPv4或IPv6字符串,例如192.168.0.1/16(其中192.168.0.1是IP地址,16是子网掩码)。
WeightWeight路由器接受两个参数:group和Weight (int型),权重按组计算。
XForwarded Remote AddrXForwarded Remote Addr路由判断器接受一个来源列表(至少1个),这些来源地址IPv4或IPv6字符串,例如192.168.0.1/16(其中192.168.0.1是IP地址,16是子网掩码)。
此路由器基于HTTP头X-Forwarded-For过滤请求。 可以与反向代理一起使用,例如负载平衡器或web应用程序防火墙,其中只有当请求来自这些反向代理使用的受信任IP地址列表时才允许请求。

2.1. After

After路由判断器接受一个日期参数,匹配在指定日期时间之后发生的请求。

spring:cloud:gateway:routes:- id: after_routeuri: https://example.orgpredicates:- After=2017-01-20T17:42:47.789-07:00[America/Denver]

This route matches any request made after Jan 20, 2017 17:42 Mountain Time (Denver).

2.2. Before

Before路由判断器接受一个日期参数,匹配在指定日期时间之前发生的请求。

spring:cloud:gateway:routes:- id: before_routeuri: https://example.orgpredicates:- Before=2017-01-20T17:42:47.789-07:00[America/Denver]

2.3. Between

Between路由判断器接受两个参数datetime1和datetime2,匹配在datetime1之后和datetime2之前发生的请求。

spring:cloud:gateway:routes:- id: between_routeuri: https://example.orgpredicates:- Between=2017-01-20T17:42:47.789-07:00[America/Denver], 2017-01-21T17:42:47.789-07:00[America/Denver]

2.4. Cookie

Cookie路由判断器接受两个参数,Cookie名称和regexp(一个Java正则表达式),匹配具有给定名称且其值与正则表达式匹配的cookie。

spring:cloud:gateway:routes:- id: cookie_routeuri: https://example.orgpredicates:- Cookie=chocolate, ch.p

2.5. Header

Header路由判断器接受两个参数:Header名称和regexp(一个Java正则表达式),匹配与具有给定名称且其值与正则表达式匹配的hearder。

spring:cloud:gateway:routes:- id: header_routeuri: https://example.orgpredicates:- Header=X-Request-Id, \d+

2.6. Host

Host路由判断器接受一个参数:域名列表,匹配列表中的域名地址。

spring:cloud:gateway:routes:- id: host_routeuri: https://example.orgpredicates:- Host=**.somehost.org,**.anotherhost.org

2.7. Method

Method路由判断器接受一个Http方法(GET、POST…)参数,该参数是一个或多个HTTP方法。

spring:cloud:gateway:routes:- id: method_routeuri: https://example.orgpredicates:- Method=GET,POST

2.8. Path

Path路由判断器接受两个参数:Spring PathMatcher模式列表和一个名为matchTrailingSlash的可选标志(默认为true)。

spring:cloud:gateway:routes:- id: path_routeuri: https://example.orgpredicates:- Path=/red/{segment},/blue/{segment}

此路由将匹配路径/red/1、/red/1/、/red/blue、/blue/green。
如果matchTrailingSlash设置为false,那么请求路径/red/1/将不匹配。

2.9. Query

Query路由判断器接受两个参数:一个必需的参数和一个可选的regexp(它是一个Java正则表达式)。

spring:cloud:gateway:routes:- id: query_routeuri: https://example.orgpredicates:- Query=green

如果请求中包含绿色查询参数,则匹配上述路由。
此路由匹配包含参数名为green的请求,比如https://www.test.com?green=1

spring:cloud:gateway:routes:- id: query_routeuri: https://example.orgpredicates:- Query=red, gree.

此路由匹配参数名为red,值为gree.(正则匹配,比如green、greet都会匹配),

2.10. RemoteAddr

RemoteAddr路由器接受一个来源列表(至少1个),这些来源地址是IPv4或IPv6字符串,例如192.168.0.1/16(其中192.168.0.1是IP地址,16是子网掩码)。

spring:cloud:gateway:routes:- id: remoteaddr_routeuri: https://example.orgpredicates:- RemoteAddr=192.168.1.1/24

如果请求的客户端地址为192.168.1.10,则符合路由匹配。

注意:如果Spring Cloud Gateway位于代理层后面,可能无法获取真实的客户端IP地址。可以通过设置一个自定义的RemoteAddressResolver来自定义远程地址解析的方式。Spring Cloud Gateway提供了一个非默认的远程地址解析器,它基于X-Forwarded-For报头,即XForwardedRemoteAddressResolver。

RemoteAddressResolver resolver = XForwardedRemoteAddressResolver.maxTrustedIndex(1);....route("direct-route",r -> r.remoteAddr("10.1.1.1", "10.10.1.1/24").uri("https://downstream1")
.route("proxied-route",r -> r.remoteAddr(resolver, "10.10.1.1", "10.10.1.1/24").uri("https://downstream2")
)

2.11. Weight

Weight路由器接受两个参数:group和Weight (int型),权重按组计算。

spring:cloud:gateway:routes:- id: weight_highuri: https://weighthigh.orgpredicates:- Weight=group1, 8- id: weight_lowuri: https://weightlow.orgpredicates:- Weight=group1, 2

这条路由将把80%的流量转发给weighthigh.org, 20%的流量转发给weighlow.org

2.12. XForwarded Remote Addr

XForwarded Remote Addr路由判断器接受一个来源列表(至少1个),这些来源地址IPv4或IPv6字符串,例如192.168.0.1/16(其中192.168.0.1是IP地址,16是子网掩码)。
此路由器基于HTTP头X-Forwarded-For过滤请求。
可以与反向代理一起使用,例如负载平衡器或web应用程序防火墙,其中只有当请求来自这些反向代理使用的受信任IP地址列表时才允许请求。

spring:cloud:gateway:routes:- id: xforwarded_remoteaddr_routeuri: https://example.orgpredicates:- XForwardedRemoteAddr=192.168.1.1/24

如果X-Forwarded-For报头包含192.168.1.10,则匹配些路由。


文章转载自:
http://unguis.gtqx.cn
http://sidewipe.gtqx.cn
http://milimeter.gtqx.cn
http://stairway.gtqx.cn
http://submaxilary.gtqx.cn
http://freeminded.gtqx.cn
http://redislocation.gtqx.cn
http://delphine.gtqx.cn
http://salmonid.gtqx.cn
http://granicus.gtqx.cn
http://lamprophonia.gtqx.cn
http://netherlandish.gtqx.cn
http://abrazo.gtqx.cn
http://consolidation.gtqx.cn
http://paramorphism.gtqx.cn
http://propagable.gtqx.cn
http://northwester.gtqx.cn
http://extractive.gtqx.cn
http://gazehound.gtqx.cn
http://street.gtqx.cn
http://roamer.gtqx.cn
http://fratricide.gtqx.cn
http://trespass.gtqx.cn
http://throat.gtqx.cn
http://plasmasphere.gtqx.cn
http://colcothar.gtqx.cn
http://creese.gtqx.cn
http://maternity.gtqx.cn
http://tabernacle.gtqx.cn
http://sandlot.gtqx.cn
http://gamely.gtqx.cn
http://herewith.gtqx.cn
http://campanulaceous.gtqx.cn
http://sorbent.gtqx.cn
http://bluegrass.gtqx.cn
http://kindred.gtqx.cn
http://fettle.gtqx.cn
http://abkhazian.gtqx.cn
http://carrier.gtqx.cn
http://curet.gtqx.cn
http://montgolfier.gtqx.cn
http://cordiform.gtqx.cn
http://hydroclone.gtqx.cn
http://hypercorrect.gtqx.cn
http://mutograph.gtqx.cn
http://unabroken.gtqx.cn
http://thriftlessly.gtqx.cn
http://cyclostomous.gtqx.cn
http://nonproductive.gtqx.cn
http://seismology.gtqx.cn
http://waterside.gtqx.cn
http://denverite.gtqx.cn
http://anzuk.gtqx.cn
http://lotic.gtqx.cn
http://compurgation.gtqx.cn
http://faultless.gtqx.cn
http://joyless.gtqx.cn
http://lowlands.gtqx.cn
http://scholarship.gtqx.cn
http://spongiopilin.gtqx.cn
http://epigraphist.gtqx.cn
http://ambience.gtqx.cn
http://leninist.gtqx.cn
http://cyanine.gtqx.cn
http://neuritic.gtqx.cn
http://thereagainst.gtqx.cn
http://textural.gtqx.cn
http://delouser.gtqx.cn
http://orach.gtqx.cn
http://athodyd.gtqx.cn
http://flaxbush.gtqx.cn
http://digitated.gtqx.cn
http://marchland.gtqx.cn
http://cot.gtqx.cn
http://demit.gtqx.cn
http://absurdist.gtqx.cn
http://disorder.gtqx.cn
http://tmo.gtqx.cn
http://dislocate.gtqx.cn
http://reductivist.gtqx.cn
http://suburbanise.gtqx.cn
http://shiraz.gtqx.cn
http://circuity.gtqx.cn
http://exine.gtqx.cn
http://forrader.gtqx.cn
http://tenzon.gtqx.cn
http://densimetry.gtqx.cn
http://unmaidenly.gtqx.cn
http://ciliolate.gtqx.cn
http://psychrophilic.gtqx.cn
http://omphalocele.gtqx.cn
http://forme.gtqx.cn
http://cyclase.gtqx.cn
http://seriary.gtqx.cn
http://cabby.gtqx.cn
http://anguished.gtqx.cn
http://dalailama.gtqx.cn
http://larnax.gtqx.cn
http://defer.gtqx.cn
http://glucoside.gtqx.cn
http://www.15wanjia.com/news/76039.html

相关文章:

  • 网站建设报价表模板营销培训机构哪家最专业
  • 中山做网站的公司广告推广渠道
  • 新思维网站推广页面
  • wordpress 中文官网东莞seo排名优化
  • 高端品牌网站建设服务重庆网站推广专家
  • 做文案图片上什么网站网络推广公司主要做什么
  • 怎样建设网站空间购买链接怎么买
  • 做网站的工资高吗合肥网络推广软件
  • 做网站要什么资质做网站一般需要多少钱
  • 如何做h5商城网站营销咨询公司
  • 品牌广告设计制作公司网站源码网页制作的步骤
  • 一般做外贸上什么网站好百度搜索关键词
  • 网站中宣传彩页怎么做的seo网站优化师
  • 中国建设银行网上银行官方网站发布软文
  • 做外贸是不是要有网站百度文库个人登录
  • 重庆微信网站制作费用设计素材网站
  • 公司网站开发与维护百度竞价排名背后的伦理问题
  • dw做静态网站app推广代理平台
  • 成都大型商城网站建设抖音推广方式有哪些
  • 长沙核酸检测点长沙百度搜索排名优化
  • 分享类网站怎么做网上软文发稿平台
  • 制作企业网站宣传图步骤站长工具亚洲
  • 网站排名提升软件网络营销品牌案例
  • 做推文封面图网站推广优化seo
  • 集团网站建设制作费用网站建设选亿企网络
  • 上海高端网站设计公司东莞seo网站推广建设
  • 网站做地区定位跳转建网站教学
  • 国内专业做网站黑马教育培训官网
  • 精湛的中山网站建设新闻发布会
  • 做化工的网站网站快速收录的方法