Azure 云服务,使用 web.config 拒绝访问子文件夹
Azure Cloud Services, deny access to subfolder using web.config
我有 PHP 我在本地 Server 2008 开发服务器上开发的应用程序,然后我将其推送到我在 Azure 云服务上的实时站点。这一切都很好。在我的一个子文件夹中,我有一个 web.config
文件,其中包含以下内容:
<configuration>
<system.webServer>
<security>
<authorization>
<remove users="*" roles="" verbs="" />
</authorization>
</security>
</system.webServer>
如果我尝试进入该文件夹,或在我的开发服务器上的浏览器中查看任何文件,我会收到消息:
401 - Unauthorized: Access is denied due to invalid credentials.
这太棒了!..如果我尝试转到我的实时站点上该文件夹中的文件,它会很好地显示该文件。它完全忽略了 web.config
文件。我已连接到我的实时站点的 运行 云实例,并且可以在其中看到 web.config
文件。
为什么它在 Azure 上被忽略,但在我的开发站点上运行良好?
如果其他人遇到同样的问题,您需要将 location
元素添加到您的根网站。config/web。cloud.config。它需要直接在 configuration
元素中,如下所示:
<configuration>
.....
.....
<location path="--folder or file--">
<system.web>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</location>
</configuration>
我有 PHP 我在本地 Server 2008 开发服务器上开发的应用程序,然后我将其推送到我在 Azure 云服务上的实时站点。这一切都很好。在我的一个子文件夹中,我有一个 web.config
文件,其中包含以下内容:
<configuration>
<system.webServer>
<security>
<authorization>
<remove users="*" roles="" verbs="" />
</authorization>
</security>
</system.webServer>
如果我尝试进入该文件夹,或在我的开发服务器上的浏览器中查看任何文件,我会收到消息:
401 - Unauthorized: Access is denied due to invalid credentials.
这太棒了!..如果我尝试转到我的实时站点上该文件夹中的文件,它会很好地显示该文件。它完全忽略了 web.config
文件。我已连接到我的实时站点的 运行 云实例,并且可以在其中看到 web.config
文件。
为什么它在 Azure 上被忽略,但在我的开发站点上运行良好?
如果其他人遇到同样的问题,您需要将 location
元素添加到您的根网站。config/web。cloud.config。它需要直接在 configuration
元素中,如下所示:
<configuration>
.....
.....
<location path="--folder or file--">
<system.web>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</location>
</configuration>