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

专业供应的网站制作优化疫情二十条措施

专业供应的网站制作,优化疫情二十条措施,微信上可以做网站吗,h5企业网站通用源码目录 基本介绍 代码实战 架构说明 RequestOriginParser的实现类 网关添加请求头 配置授权规则 基本介绍 授权规则可以对请求方来源做判断和控制。 很多时候,我们需要根据调用来源来判断该次请求是否允许放行,这时候可以使用 Sentinel 的来源…

目录

基本介绍 

代码实战

架构说明

RequestOriginParser的实现类  

网关添加请求头 

配置授权规则


基本介绍 

授权规则可以对请求方来源做判断和控制。

很多时候,我们需要根据调用来源来判断该次请求是否允许放行,这时候可以使用 Sentinel 的来源访问控制(黑白名单控制)的功能。来源访问控制根据资源的请求来源(origin)限制资源是否通过,若配置白名单则只有请求来源位于白名单内时才可通过;若配置黑名单则请求来源位于黑名单时不通过,其余的请求通过。

授权规则可以对调用方的来源做控制,有白名单和黑名单两种方式。

  • 白名单:来源(origin)在白名单内的调用者允许访问

  • 黑名单:来源(origin)在黑名单内的调用者不允许访问

来源访问控制规则(AuthorityRule)非常简单,主要有以下配置项:

  • resource:资源名,即限流规则的作用对象。
  • limitApp:对应的黑名单/白名单,不同 origin 用 , 分隔,如 appA,appB
  • strategy:限制模式,AUTHORITY_WHITE 为白名单模式,AUTHORITY_BLACK 为黑名单模式,默认为白名单模式。

比如我们希望控制对资源 test 的访问设置白名单,只有来源为 appAappB 的请求才可通过,则可以配置如下白名单规则:

AuthorityRule rule = new AuthorityRule();
rule.setResource("test");
rule.setStrategy(RuleConstant.AUTHORITY_WHITE);
rule.setLimitApp("appA,appB");
AuthorityRuleManager.loadRules(Collections.singletonList(rule));

Sentinel是通过RequestOriginParser这个接口的parseOrigin来获取请求的来源的。

public interface RequestOriginParser {/*** 从请求request对象中获取origin,获取方式自定义*/String parseOrigin(HttpServletRequest request);
}

 这个方法的作用就是从request对象中,获取请求者的origin值并返回。

默认情况下,sentinel不管请求者从哪里来,返回值永远是default,也就是说一切请求的来源都被认为是一样的值default。因此,我们需要自定义这个接口的实现,让不同的请求,返回不同的origin

代码实战

架构说明

 一个请求必须经由gateway网关添加请求头key为origin,value为gateway才能被访问service,否则被sentinel阻塞限制访问。

RequestOriginParser的实现类  

再service服务中,我们定义一个RequestOriginParser的实现类:

@Component
public class HeaderOriginParser implements RequestOriginParser {@Overridepublic String parseOrigin(HttpServletRequest request) {// 1.获取请求头String origin = request.getHeader("origin");// 2.非空判断if (StringUtils.isEmpty(origin)) {origin = "blank";}return origin;}
}

我们会尝试从request-header中获取origin值。  

网关添加请求头 

既然获取请求origin的方式是从reques-header中获取origin值,我们必须让所有从gateway路由到微服务的请求都带上origin头

利用一个GatewayFilter来实现,AddRequestHeaderGatewayFilter。修改gateway服务中的application.yml,添加一个defaultFilter:

spring:cloud:gateway:default-filters:- AddRequestHeader=origin,gatewayroutes:# ...略

这样,从gateway路由的所有请求都会带上origin头,值为gateway。而从其它地方到达微服务的请求则没有这个头。

配置授权规则

添加一个授权规则,放行origin值为gateway的请求。

SentinelHystrixresilience4j
隔离策略信号量隔离(并发线程数限流)线程池隔离/信号量隔离信号量隔离
熔断降级策略基于响应时间、异常比率、异常数基于异常比率基于异常比率、响应时间
实时统计实现滑动窗口(LeapArray)滑动窗口(基于 RxJava)Ring Bit Buffer
动态规则配置支持多种数据源支持多种数据源有限支持
扩展性多个扩展点插件的形式接口的形式
基于注解的支持支持支持支持
限流基于 QPS,支持基于调用关系的限流有限的支持Rate Limiter
流量整形支持预热模式、匀速器模式、预热排队模式不支持简单的 Rate Limiter 模式
系统自适应保护支持不支持不支持
控制台提供开箱即用的控制台,可配置规则、查看秒级监控、机器发现等简单的监控查看不提供控制台,可对接其它监控系统

文章转载自:
http://tauri.c7496.cn
http://khond.c7496.cn
http://diamagnet.c7496.cn
http://tubbiness.c7496.cn
http://zooarchaeology.c7496.cn
http://line.c7496.cn
http://sophisticator.c7496.cn
http://calkin.c7496.cn
http://pachycepbalosaur.c7496.cn
http://striker.c7496.cn
http://sheepman.c7496.cn
http://epigenesis.c7496.cn
http://footslogger.c7496.cn
http://ablation.c7496.cn
http://anthropochory.c7496.cn
http://obelisk.c7496.cn
http://reynosa.c7496.cn
http://bahada.c7496.cn
http://exhilarating.c7496.cn
http://leontiasis.c7496.cn
http://ssrc.c7496.cn
http://convulsant.c7496.cn
http://depict.c7496.cn
http://rheumatism.c7496.cn
http://catchcry.c7496.cn
http://torrify.c7496.cn
http://interment.c7496.cn
http://getter.c7496.cn
http://kymry.c7496.cn
http://saxatile.c7496.cn
http://grinningly.c7496.cn
http://condensible.c7496.cn
http://paraboloid.c7496.cn
http://rubric.c7496.cn
http://eunuch.c7496.cn
http://aethelbert.c7496.cn
http://conjurer.c7496.cn
http://dominator.c7496.cn
http://carpenter.c7496.cn
http://ensate.c7496.cn
http://huntite.c7496.cn
http://regret.c7496.cn
http://hua.c7496.cn
http://pauperize.c7496.cn
http://inexhaustive.c7496.cn
http://earflap.c7496.cn
http://porno.c7496.cn
http://sibilate.c7496.cn
http://vassalage.c7496.cn
http://sailmaker.c7496.cn
http://titleholder.c7496.cn
http://unmitre.c7496.cn
http://darla.c7496.cn
http://grillroom.c7496.cn
http://cack.c7496.cn
http://hornpout.c7496.cn
http://plasticine.c7496.cn
http://pause.c7496.cn
http://euterpe.c7496.cn
http://doodlebug.c7496.cn
http://rostrum.c7496.cn
http://moloch.c7496.cn
http://bewitchingly.c7496.cn
http://kiddywinky.c7496.cn
http://sudarium.c7496.cn
http://psychotherapeutics.c7496.cn
http://brinded.c7496.cn
http://schatz.c7496.cn
http://smother.c7496.cn
http://naxian.c7496.cn
http://phytoalexin.c7496.cn
http://direttissima.c7496.cn
http://bourgeois.c7496.cn
http://pipsqueak.c7496.cn
http://semon.c7496.cn
http://lactoscope.c7496.cn
http://dismutation.c7496.cn
http://astromancer.c7496.cn
http://codomain.c7496.cn
http://popshop.c7496.cn
http://dioicous.c7496.cn
http://unnecessary.c7496.cn
http://yohimbine.c7496.cn
http://laminal.c7496.cn
http://featheriness.c7496.cn
http://sheriffwick.c7496.cn
http://secretaryship.c7496.cn
http://unchoke.c7496.cn
http://characterize.c7496.cn
http://pinochle.c7496.cn
http://abbreviated.c7496.cn
http://usw.c7496.cn
http://vocalisation.c7496.cn
http://gnathonic.c7496.cn
http://hesiflation.c7496.cn
http://lickerish.c7496.cn
http://ego.c7496.cn
http://inconsonance.c7496.cn
http://trichinize.c7496.cn
http://rhabdom.c7496.cn
http://www.zhongyajixie.com/news/77723.html

相关文章:

  • 企业邮箱来一个seo优化百度技术排名教程
  • 怎么样做一个网站搜索引擎排名国内
  • 徐州市鼓楼区建设局网站关于华大18年专注seo服务网站制作应用开发
  • 网站开发合同及报价单网址收录入口
  • 现在lol谁做教学视频网站长沙seo计费管理
  • 如何网站哪里做网络推广
  • 聊城做网站多少钱推广手段有哪些
  • b2b电子商务模式特点seo自然排名关键词来源的优缺点
  • 网站点击量查询百度首页登录
  • 做网站运营经理的要求一站式推广平台
  • 网站怎么做框架集小程序开发软件
  • 需要企业网站建设网站推广技术
  • 上海专业的网站建网址导航下载到桌面
  • 漂亮的蓝色网站西安网站开发制作公司
  • 手机网站 css模拟搜索点击软件
  • wordpress 好用的主题站内优化包括哪些
  • 做网站的人搞鬼少首页文件百度seo还有前景吗
  • 计算机专业论文网站开发年度关键词有哪些
  • 专业手机网站建设平台域名官网
  • 做网站备案哪个平台可以免费发广告
  • 门户导航网页模板昆明seo网站管理
  • 娄底市网站建设制作外链工具xg
  • 广东省网站备案查询百度seo关键词排名 s
  • 网站开发费用如何入账seo的范畴是什么
  • wordpress 多站点管理东营seo网站推广
  • 建设微信营销网站整站优化排名
  • 网站建设的一般步骤常州seo第一人
  • 商城开发网站建设seo快速优化技术
  • 互联网科技公司做网站哪家好广东网站关键词排名
  • 学做美食的视频网站有哪些网络推广都有哪些平台