如何在windows IIS 中配置特定路徑允許匿名存取並保持其他路徑使用Windows 驗證
解鎖Authentication 設定節
步驟1:解鎖配置節
- 在
IIS 管理器中,選擇你的伺服器節點。 - 在中間面板中雙擊
配置编辑器。 - 在
配置编辑器中,選擇system.webServer/security/authentication。 - 在右側面板中,點選
操作中的解锁。
具體解鎖子設置
你需要解鎖每一個相關的子設置,如anonymousAuthentication和windowsAuthentication。
解鎖匿名身份驗證
- 在
配置编辑器中,導航到system.webServer/security/authentication/anonymousAuthentication。 - 在右側面板中,點選
操作中的解锁。
解鎖Windows 驗證
- 在
配置编辑器中,導航到system.webServer/security/authentication/windowsAuthentication。 - 在右側面板中,點選
操作中的解锁。
確認Web.config 文件
確認你的web.config文件內容如下:
XML<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<security>
<authentication>
<anonymousAuthentication enabled="false" />
<windowsAuthentication enabled="true" />
</authentication>
</security>
<authorization>
<add accessType="Allow" roles="*" />
</authorization>
</system.webServer>
<location path="aip">
<system.webServer>
<security>
<authentication>
<anonymousAuthentication enabled="true" />
<windowsAuthentication enabled="false" />
</authentication>
</security>
</system.webServer>
</location>
</configuration>
重啟IIS
解鎖配置節並修改web.config文件後,重新啟動IIS:
- 開啟命令提示字元(以管理員身份執行)。
- 輸入並執行以下命令:指令
iisreset
驗證配置
透過瀏覽器訪問https://facelock.nia.gov.tw/aip,確保該路徑可以匿名訪問。存取其他路徑,確保它們仍然需要Windows 驗證。
透過上述步驟,你應該能夠成功設定IIS 允許特定路徑匿名訪問,同時保持其他路徑使用Windows 驗證。如果在過程中遇到任何問題,請隨時告訴我。
留言
張貼留言