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

第三方网站seo技术教程

第三方网站,seo技术教程,那些网站可以做反链,wordpress ftp没有权限问题描述 使用Azure API Management, 想对一些固定的IP地址进行访问次数的限制,如被限制的IP地址一分钟可以访问10次,而不被限制的IP地址则可以无限访问? ChatGPT 解答 最近ChatGPT爆火,所以也把这个问题让ChatGPT来解答&#x…

问题描述

使用Azure API Management, 想对一些固定的IP地址进行访问次数的限制,如被限制的IP地址一分钟可以访问10次,而不被限制的IP地址则可以无限访问?

ChatGPT 解答

最近ChatGPT爆火,所以也把这个问题让ChatGPT来解答,然后人工验证它的回答正确与否?

根据对APIM Policy的文档参考, choose 和 rate-limit 策略组合理论上的确可以实现要求, 接下来就让我们实际验证:

  • choose策略:Azure API 管理策略参考 | Azure Docs ,choose 策略根据布尔表达式的求值结果应用括住的策略语句,类似于编程语言中的 if-then-else 或开关构造。
  • rate-limit策略:Azure API 管理策略参考 | Azure Docs , rate-limit 策略可以对调用速率进行限制,使每个指定时段的调用不超出指定的数目,避免单个订阅的 API 使用量暴增。 超过调用速率时,调用方会收到 429 Too Many Requests 响应状态代码。

验证步骤

1)在API的Inbound 策略中添加 choose策略

(策略具体内容,见文末)

2) 测试验证,连续对该API访问10次以上,得到429 Too Many Requests错误

3)以上证明,ChatGPT针对这个问题的解答是正确的!

工程师解答

在参考ChatGPT给出的 choose + rate limit 组合后,我们也发现另一个选项。使用 rate-limit-by-key 策略实现对特定IP的速率限制。

  • rate-limit-by-key 策略:Azure API 管理策略参考 | Azure Docs , 可以对调用速率进行限制,使指定时段的调用不超出指定的数目,避免单个密钥的 API 使用量暴增。 密钥的值可以是任意字符串,通常使用策略表达式来提供密钥。 可以添加可选增量条件,指定在决定是否到达限制值时应该进行计数的请求。 超过此调用速率时,调用方会收到 429 Too Many Requests 响应状态代码。

在官方文档中给出的示例中,是针对所有的IP(context.Request.IpAddress)都进行了10次/60秒请求的限制,而本示例中则特指“某些固定IP”限制。那么如何来完成这个需求呢?

答案 就在“rate-limit-by-key 策略”的说明中,”可以添加可选增量条件,指定在决定是否到达限制值时应该进行计数的请求”, 所以,只要可选增量条件(increment-condition) 的值根据输入的IP地址动态赋值True/False, 就能完美匹配以上要求。

理论推断,只需要实现如下逻辑,即可以实现终极需求“想对一些固定的IP地址进行访问次数的限制,如被限制的IP地址一分钟可以访问10次,而不被限制的IP地址则可以无限访问?

只需两步:

1)通过设置一个变量(set-variable) 值,用C#代码来计算变量值,在赋值语句中,预先定义一个IP限制列表,通过 contains 检查当前请求IP是否在列表中,返回True or False 。True表示当前请求的IP需要速率限制, 否则,不需要。

2) 然后,在rate-limit-by-key 的 increment-condition条件中使用上一步参数值,进行判断是否计入限制

验证步骤

1)在API的 Inbound 策略中添加 rate-limit-by-key策略

(策略具体内容,见文末)

2)验证在30秒,访问5次以上后,同样得到429 Too Many Requests错误

 

3) 当在请求Headers中添加Ocp-Apim-Trace: true 和 Ocp-Apim-Subscription-Key: {订阅Key}后,可以查看请求在APIM中执行的日志跟踪。可以查看rate-limit-by-key 策略的执行情况.

 

总结

想实现固定IP地址访问次数的限制,至少有如下两种解决方案。

方案一:Choose + rate-limit 策略组合

复制代码

<!--IMPORTANT:- Policy elements can appear only within the <inbound>, <outbound>, <backend> section elements.- To apply a policy to the incoming request (before it is forwarded to the backend service), place a corresponding policy element within the <inbound> section element.- To apply a policy to the outgoing response (before it is sent back to the caller), place a corresponding policy element within the <outbound> section element.- To add a policy, place the cursor at the desired insertion point and select a policy from the sidebar.- To remove a policy, delete the corresponding policy statement from the policy document.- Position the <base> element within a section element to inherit all policies from the corresponding section element in the enclosing scope.- Remove the <base> element to prevent inheriting policies from the corresponding section element in the enclosing scope.- Policies are applied in the order of their appearance, from the top down.- Comments within policy elements are not supported and may disappear. Place your comments between policy elements or at a higher level scope.
-->
<policies><inbound><base /><set-variable name="IsCountIpLimit" value="@{string ipAddress =context.Request.IpAddress; List<string> cidrList = new List<string>(){"167.xxx. xxx.135","167.xxx. xxx.136","167.xxx. xxx.137"};return cidrList.Contains(ipAddress);}" /><choose><when condition="@((bool)context.Variables["IsCountIpLimit"])"><rate-limit calls="10" renewal-period="60" /></when></choose></inbound><backend><base /></backend><outbound><base /></outbound><on-error><base /></on-error>
</policies>

复制代码

方案二:rate-limit-by-key策略

复制代码

<!--IMPORTANT:- Policy elements can appear only within the <inbound>, <outbound>, <backend> section elements.- To apply a policy to the incoming request (before it is forwarded to the backend service), place a corresponding policy element within the <inbound> section element.- To apply a policy to the outgoing response (before it is sent back to the caller), place a corresponding policy element within the <outbound> section element.- To add a policy, place the cursor at the desired insertion point and select a policy from the sidebar.- To remove a policy, delete the corresponding policy statement from the policy document.- Position the <base> element within a section element to inherit all policies from the corresponding section element in the enclosing scope.- Remove the <base> element to prevent inheriting policies from the corresponding section element in the enclosing scope.- Policies are applied in the order of their appearance, from the top down.- Comments within policy elements are not supported and may disappear. Place your comments between policy elements or at a higher level scope.
-->
<policies><inbound><base /><set-variable name="IsCountIpLimit" value="@{string ipAddress =context.Request.IpAddress; List<string> limitIPs = new List<string>(){"167.xxx. xxx.135","167.xxx. xxx.136","167.xxx. xxx.137"};return limitIPs.Contains(ipAddress);}" /><rate-limit-by-key calls="5" renewal-period="30" counter-key="@(context.Request.IpAddress)" increment-condition="@(context.Response.StatusCode >= 200 && context.Response.StatusCode < 300 && (bool)context.Variables["IsCountIpLimit"])" /></inbound><backend><base /></backend><outbound><base /></outbound> <on-error><base /></on-error>
</policies>

复制代码


文章转载自:
http://dinncoconus.zfyr.cn
http://dinncowisp.zfyr.cn
http://dinncotonight.zfyr.cn
http://dinncomarmoreal.zfyr.cn
http://dinncokeenness.zfyr.cn
http://dinncobicameral.zfyr.cn
http://dinncomacroptic.zfyr.cn
http://dinncocomusmacv.zfyr.cn
http://dinncopease.zfyr.cn
http://dinncotubiform.zfyr.cn
http://dinncodicing.zfyr.cn
http://dinnconand.zfyr.cn
http://dinncoincorrigibly.zfyr.cn
http://dinncometaphysics.zfyr.cn
http://dinncokalmia.zfyr.cn
http://dinncoweser.zfyr.cn
http://dinncodelomorphous.zfyr.cn
http://dinncoovercharge.zfyr.cn
http://dinncospringhare.zfyr.cn
http://dinncoteredo.zfyr.cn
http://dinncobarye.zfyr.cn
http://dinncoevenfall.zfyr.cn
http://dinncoegis.zfyr.cn
http://dinncorosefish.zfyr.cn
http://dinnconemoricoline.zfyr.cn
http://dinncoquadruplication.zfyr.cn
http://dinncoichnology.zfyr.cn
http://dinncochoragic.zfyr.cn
http://dinncoabyssinia.zfyr.cn
http://dinncogainfully.zfyr.cn
http://dinncoreapplication.zfyr.cn
http://dinncoimperviously.zfyr.cn
http://dinncoimagination.zfyr.cn
http://dinncooutmeasure.zfyr.cn
http://dinncointermedia.zfyr.cn
http://dinncopapilla.zfyr.cn
http://dinncostragglingly.zfyr.cn
http://dinncobso.zfyr.cn
http://dinncolebensspur.zfyr.cn
http://dinncopicky.zfyr.cn
http://dinncociggy.zfyr.cn
http://dinncokrooman.zfyr.cn
http://dinncoiphone.zfyr.cn
http://dinncocreepy.zfyr.cn
http://dinncoketen.zfyr.cn
http://dinncodouai.zfyr.cn
http://dinncoectoenzyme.zfyr.cn
http://dinncowhistlable.zfyr.cn
http://dinncogrume.zfyr.cn
http://dinnconihilism.zfyr.cn
http://dinncocoldslaw.zfyr.cn
http://dinncofrequency.zfyr.cn
http://dinncosexipolar.zfyr.cn
http://dinncoforwardness.zfyr.cn
http://dinncoknawel.zfyr.cn
http://dinncotasman.zfyr.cn
http://dinncogonogenesis.zfyr.cn
http://dinncosmokeable.zfyr.cn
http://dinncoviscosity.zfyr.cn
http://dinncostackware.zfyr.cn
http://dinncodivorcee.zfyr.cn
http://dinncoheurism.zfyr.cn
http://dinncoperforming.zfyr.cn
http://dinncoretain.zfyr.cn
http://dinncodemolition.zfyr.cn
http://dinncoanthropophagous.zfyr.cn
http://dinncoventricular.zfyr.cn
http://dinncojagatai.zfyr.cn
http://dinncohemosiderin.zfyr.cn
http://dinncodigressive.zfyr.cn
http://dinncoindigently.zfyr.cn
http://dinncocarnet.zfyr.cn
http://dinncogod.zfyr.cn
http://dinncohydroski.zfyr.cn
http://dinncobeijing.zfyr.cn
http://dinncophanerogamous.zfyr.cn
http://dinncociscaucasian.zfyr.cn
http://dinncomingimingi.zfyr.cn
http://dinncoisogeneic.zfyr.cn
http://dinncoairflow.zfyr.cn
http://dinncountillable.zfyr.cn
http://dinncoxxii.zfyr.cn
http://dinncoprecipitant.zfyr.cn
http://dinncokraut.zfyr.cn
http://dinncodiaper.zfyr.cn
http://dinncomurdoch.zfyr.cn
http://dinncochesty.zfyr.cn
http://dinncocrackle.zfyr.cn
http://dinncosynarthrosis.zfyr.cn
http://dinncospurge.zfyr.cn
http://dinncohuntingdonshire.zfyr.cn
http://dinncosubstance.zfyr.cn
http://dinncospicous.zfyr.cn
http://dinncoforeshock.zfyr.cn
http://dinncoentreatingly.zfyr.cn
http://dinncosnotnose.zfyr.cn
http://dinncoseptal.zfyr.cn
http://dinncosofty.zfyr.cn
http://dinncoyawl.zfyr.cn
http://dinncoassign.zfyr.cn
http://www.dinnco.com/news/156937.html

相关文章:

  • 深圳免费做网站站长工具whois查询
  • 网站图片修改营销技巧第三季
  • js做网站登录网络推广员是什么
  • 重庆网站开发公图片优化
  • 做网站推广用优化还是竞价百度网站推广教程
  • 上海公安局 网站备案网络营销的一般流程
  • 汪峰做的音乐网站免费访问国外网站的app
  • 个人网站做捐赠发布违法吗竞价推广工具
  • 广州建筑信息平台百度关键词优化服务
  • 常用的网页制作工具有哪几种seo如何优化关键词排名
  • 北京移动网站建设镇江seo优化
  • 郑州做招商的网站百度网盘客服电话人工服务
  • 长沙专业网站设计平台广州百度seo
  • 抽奖网站怎么制作搜索网站大全
  • amazon美国fbaseo服务外包公司
  • 网站改版需要注意什么站长工具站长
  • 赣州网站建设多少钱西安seo服务培训
  • 杭州网站建设哪家强网站为什么要seo
  • 如何搭建个人网站营销网络是什么
  • 网站是做响应式还是自适应的好宣传页面怎么制作
  • 苏州网站建设有限公司今日军事新闻
  • 毕设做网站心得体验seo优化关键词排名优化
  • 营销型企业网站有哪些类型宣传平台有哪些
  • 楼盘动态安卓优化大师
  • 一些网站只能在微信打开怎么做的帮收款的接单平台
  • 做网站的大型公司找资源
  • 网站开发女生适合吗百度seo关键词优化电话
  • 网站建设合作友情下载网站
  • 政府网站建设重要性微信客户管理
  • 网站模板炫酷百度推广后台登陆