如何在windows IIS 中配置特定路徑允許匿名存取並保持其他路徑使用Windows 驗證


解鎖Authentication 設定節

步驟1:解鎖配置節

  1. IIS 管理器中,選擇你的伺服器節點。
  2. 在中間面板中雙擊配置编辑器
  3. 配置编辑器中,選擇system.webServer/security/authentication
  4. 在右側面板中,點選操作中的解锁

具體解鎖子設置

你需要解鎖每一個相關的子設置,如anonymousAuthenticationwindowsAuthentication

解鎖匿名身份驗證

  1. 配置编辑器中,導航到system.webServer/security/authentication/anonymousAuthentication
  2. 在右側面板中,點選操作中的解锁

解鎖Windows 驗證

  1. 配置编辑器中,導航到system.webServer/security/authentication/windowsAuthentication
  2. 在右側面板中,點選操作中的解锁

確認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:

  1. 開啟命令提示字元(以管理員身份執行)。
  2. 輸入並執行以下命令:
    指令
    iisreset

驗證配置

透過瀏覽器訪問https://facelock.nia.gov.tw/aip,確保該路徑可以匿名訪問。存取其他路徑,確保它們仍然需要Windows 驗證。

透過上述步驟,你應該能夠成功設定IIS 允許特定路徑匿名訪問,同時保持其他路徑使用Windows 驗證。如果在過程中遇到任何問題,請隨時告訴我。

感謝提供截圖。根據你提供的信息,你需要確保authentication配置節已經在伺服器級別上解鎖。以下是詳細步驟:

解鎖Authentication 設定節

步驟1:解鎖配置節

  1. IIS 管理器中,選擇你的伺服器節點。
  2. 在中間面板中雙擊配置编辑器
  3. 配置编辑器中,選擇system.webServer/security/authentication
  4. 在右側面板中,點選操作中的解锁

具體解鎖子設置

你需要解鎖每一個相關的子設置,如anonymousAuthenticationwindowsAuthentication

解鎖匿名身份驗證

  1. 配置编辑器中,導航到system.webServer/security/authentication/anonymousAuthentication
  2. 在右側面板中,點選操作中的解锁

解鎖Windows 驗證

  1. 配置编辑器中,導航到system.webServer/security/authentication/windowsAuthentication
  2. 在右側面板中,點選操作中的解锁

確認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:

  1. 開啟命令提示字元(以管理員身份執行)。
  2. 輸入並執行以下命令:
    指令
    iisreset

驗證配置

透過瀏覽器訪問https://facelock.nia.gov.tw/aip,確保該路徑可以匿名訪問。存取其他路徑,確保它們仍然需要Windows 驗證。

透過上述步驟,你應該能夠成功設定IIS 允許特定路徑匿名訪問,同時保持其他路徑使用Windows 驗證。如果在過程中遇到任何問題,請隨時告訴我。

留言

這個網誌中的熱門文章

windows server 「虛擬化型保護的程式碼完整性」(Virtualization Based Protection of Code Integrity,VBS) 功能說明與設定

linux server - 檢查nvidia driver 異常並自動重新開機

Docker 應用: 再以建置好container狀況下 如何透過json設定檔設定 在修改 Working Directory 和 Restart Policy 設定