在Azure的暂存插槽中允许来自Webjob的流量 [英] Allow traffic from a webjob in a staging slot in Azure

查看:72
本文介绍了在Azure的暂存插槽中允许来自Webjob的流量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Azure中的暂存插槽,我只是在其中允许某些IP对其进行访问.我在web.config文件中写了以下规则:

I'm using a staging slot in Azure, where I just allow some IP's to have access to it. I have written the below rule in the web.config file:

<rule name="Block unauthorized traffic to staging sites" stopProcessing="true">
         <match url=".*" />
         <conditions>              
           <add input="{HTTP_HOST}" pattern="^mydomain\-mydomainslot1\."/>
           <!-- white listed IP addresses -->
           <add input="{REMOTE_ADDR}" pattern="ip1" negate="true"/>
           <add input="{REMOTE_ADDR}" pattern="ip2" negate="true"/>        
         </conditions>
         <action type="CustomResponse" statusCode="403" statusReason="Forbidden"
         statusDescription="Site is not accessible" />
       </rule>

该插槽接受来自我的域ip1和ip2的流量.但是,我有一个Webjob(位于插槽中),该Webjob使PostAsJsonAsync调用插槽URL,并且我收到禁止回答.我不知道该webjob的IP地址(应该与网站/广告位相同),但是无论如何,我没有一个静态IP地址可以在规则中使用它.我应该如何解决这个问题?是否有另一种无需在Azure中保留IP即可解决此问题的方法?

The slot accepts traffic from my domain, ip1 and ip2. However, I have a webjob (which is in the slot) that makes a PostAsJsonAsync call the to the slot url, and I receive a forbidden as an answer. I don't know the IP address of the webjob (it is supposed to be the same as the website/slot), but anyway, I don't have a static IP address to use it in the rule. How should I solve this problem? Is there another way of solving this issue without reserving an IP in Azure?

推荐答案

好,我知道了.无需保留IP.我刚刚将所有可能的出站IP添加到了我的web.config中,并且现在可以正常工作了.我错过了入站IP和出站IP不同的事实.该Web作业具有与网站相同的虚拟IP,但是可以有多个出站IP.

Ok I have figured out. Theres no need to reserve an IP. I have just added all the possible outbound IPs to my web.config and it's working now. I was missing the fact that the inbound and outbound IPs are different. The webjob has the same virtual IP as the website, but there can be multiple outbound IPs. Those outbound IPs are in the Azure Portal.

这篇关于在Azure的暂存插槽中允许来自Webjob的流量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆