共用方式為


設定 Azure Stack HCI 的 Proxy 設定

適用於:Azure Stack HCI 版本 22H2

本文說明如果您的網路使用 Proxy 伺服器進行因特網存取,如何設定 Azure Stack HCI 的 Proxy 設定。

如需 Azure Stack HCI 輸出端點的防火牆需求和內部規則和埠的相關信息,請參閱 Azure Stack HCI 的防火牆需求。

開始之前

開始設定 Proxy 設定之前,請確定:

  • 您可以存取您設定 Proxy 設定的 Azure Stack HCI 叢集。 您也有本機系統管理員認證,可存取 Azure Stack HCI 叢集中的伺服器。

  • 您知道 Proxy 伺服器名稱或 IP 位址和連接埠(選擇性)。 如果您沒有此資訊,請連絡您的網路管理員。

以下是設定 Proxy 設定之前要記住的一些其他考慮:

  • 瞭解 Azure Stack HCI 的不同元件和功能,Proxy 設定是分開的。 您必須設定所有必要元件的 Proxy 設定,以及您計劃使用的任何其他功能。

  • 為了簡化系統管理,我們建議將相同的 Proxy 設定保留在不同的元件和功能。

  • 由於與儲存已驗證的使用者認證相關聯的安全性考慮,我們不支援已驗證的 Proxy。

Azure Stack HCI 的 Proxy 需求

如果您的網路使用 Proxy 伺服器進行因特網存取,您必須為 Azure Stack HCI 設定下列 Proxy:

  • Azure Stack HCI 操作系統的 Proxy。 成功註冊時需要此 Proxy。
  • 已啟用 Azure Arc 之伺服器的 Proxy。 成功註冊時需要此 Proxy。
  • Microsoft更新和叢集雲端見證的 Proxy。 只有在您使用 Microsoft Update 和 Cluster Cloud Witness 時,才需要此 Proxy。
  • Azure 服務的 Proxy。 只有在您使用任何其他功能時,才需要此 Proxy,例如 Azure Kubernetes Services (AKS) 混合式、Azure Arc VM 管理或 Azure 監視器。

下列各節說明如何設定這些 Proxy 設定。

設定 Azure Stack HCI 作業系統的 Proxy 設定

您必須設定 Azure Stack HCI 作業系統的 Proxy,才能 將叢集註冊至 Azure

安裝模組 WinInetProxy 以執行本節中的命令。 如需模組及其安裝方式的相關信息,請參閱 PowerShell 資源庫 |WinInetProxy 0.1.0。 如需 PowerShell 腳本的相關信息 WinInetProxy ,請參閱 WinInetProxy.psm1

注意

如果您因為沒有因特網存取而無法將模組安裝 WinInetProxy 到叢集節點,建議您將模組下載到您的管理計算機,然後手動將模組傳輸到您要執行模組的叢集節點。 您也可以使用 Start-BitsTransfer PowerShell Cmdlet,在管理計算機與伺服器之間傳輸一或多個檔案。 若要設定 Azure Stack HCI 作業系統的 Proxy 設定,請在叢集中的每個伺服器上以系統管理員身分執行下列 PowerShell 命令:

  1. 透過遠端桌面通訊協定 (RDP) 連線到 Azure Stack HCI 叢集中的伺服器,然後開啟 PowerShell 工作階段。

  2. 若要在安裝 WinInetProxy 模組之後設定 Proxy 設定,請執行下列 Cmdlet:

    Set-WinInetProxy -ProxySettingsPerUser 0 -ProxyServer <Proxy_Server_Address:Proxy_Port> -ProxyBypass <URLs to bypass>
    

    其中:

    • ProxySettingsPerUser 指定 Proxy 設定是否為每部電腦或每個使用者。

      • 0 - 每部機器都有 Proxy 設定。
      • 1 (預設值) - Proxy 設定是每個使用者。
      • 如果未提供任何值,則會改用環境變數 ProxySettingsPerUser ,如果有的話。
    • ProxyServer 會以 [Proxy_Server_Address]:[Proxy_Port] 格式指定 Proxy 伺服器端點。 例如: proxy.contoso.com:8080

    • ProxyBypass 指定略過 參數所 -ProxyServer 設定 Proxy 伺服器的主機 URL 清單。 例如,您可以設定 -ProxyBypass <local> 為略過本機內部網路 URL。

    以下是命令使用方式的範例:

    Set-WinInetProxy -ProxySettingsPerUser 0 -ProxyServer proxy.contoso.com:8080 -ProxyBypass "localhost,127.0.0.1,.svc,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,*.contoso.com"
    

若要移除 Proxy 設定,請執行不含自變數的 PowerShell 命令 Set-WinInetProxy

設定已啟用 Azure Arc 的伺服器 Proxy 設定

您必須先為已啟用 Azure Arc 的伺服器設定 Proxy,才能 將叢集註冊至 Azure

若要設定 Proxy 伺服器環境變數,請在叢集中的每個伺服器上以系統管理員身分執行下列命令:

# If a proxy server is needed, execute these commands with the proxy URL and port.
[Environment]::SetEnvironmentVariable("HTTPS_PROXY", "http://ProxyServerFQDN:port", "Machine")
$env:HTTPS_PROXY = [System.Environment]::GetEnvironmentVariable("HTTPS_PROXY", "Machine")
[Environment]::SetEnvironmentVariable("HTTP_PROXY", "10.10.42.200:8080/", "Machine")
$env:HTTP_PROXY = [System.Environment]::GetEnvironmentVariable("HTTP_PROXY", "Machine")
# For the changes to take effect, the agent services need to be restarted after the proxy environment variable is set.
Restart-Service -Name himds, ExtensionService, GCArcService

執行下列命令確認已套用設定:

echo "https :" $env:https_proxy "http :" $env:http_proxy

若要設定無 Proxy 環境變數,請在叢集中的每個伺服器上以系統管理員身分執行下列命令:

$no_proxy = "localhost,127.0.0.1,.svc,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,.contoso.com"
[Environment]::SetEnvironmentVariable("NO_PROXY", $no_proxy, "Machine")

若要移除 Proxy 設定,請在叢集中的每個伺服器上以系統管理員身分執行下列命令:

[Environment]::SetEnvironmentVariable("HTTPS_PROXY", $null, "Machine") 
$env:HTTPS_PROXY = [System.Environment]::GetEnvironmentVariable("HTTPS_PROXY", "Machine")
# For the changes to take effect, the agent services need to be restarted after the proxy environment variable removed. 
Restart-Service -Name himds, ExtensionService, GCArcService

如需已啟用 Azure Arc 之伺服器的 Proxy 設定詳細資訊,請參閱 管理和維護連線的電腦代理程式

設定Microsoft更新和叢集雲端見證的 Proxy 設定

您可以使用 WinHTTP autoproxy 自動設定 Microsoft Update 和 Cluster Cloud Witness 的 Proxy 設定,或使用命令行公用程式手動netsh設定。

  • 若要手動設定 Microsoft Update 和 Cluster Cloud Witness 的 Proxy 設定,請在命令提示字元中輸入:

    netsh winhttp set proxy Proxy_Server_Address:Proxy_Port
    
  • 若要檢視或驗證目前的 WinHTTP Proxy 組態,請在命令提示字元中輸入:

    netsh winhttp show proxy
    
  • 若要指定略過 Proxy 伺服器的主機 URL 清單,請在命令提示字元中輸入:

    netsh winhttp set proxy Proxy_Server_Address:Proxy_Port bypass-list="<URL to bypass>"
    
  • 若要改為在計算機層級設定 Internet Explorer (IE) Proxy 設定,請將 Proxy 組態匯 WinInet 入至 WinHTTP。 若要這樣做,請在命令提示字元中輸入:

    netsh winhttp import proxy source=ie
    
  • 若要移除 Microsoft Update 和 Cluster Cloud Witness 的 Proxy 組態,請在命令提示字元中輸入:

    netsh winhttp reset proxy
    

設定 Azure 服務的 Proxy 設定

如果您使用 或計劃使用下列任一 Azure 服務,請參閱下列文章,以取得如何為每個 Azure 服務設定 Proxy 伺服器設定的相關信息:

下一步

如需詳細資訊,請參閱: