透過 Proxy 存取後端

組態伺服器可以透過 HTTP 或 HTTPS Proxy 存取 Git 或 Vault 後端。此行為由 proxy.httpproxy.https 下的設定控制,適用於 Git 或 Vault。這些設定是每個儲存庫的,因此如果您使用複合環境儲存庫,則必須為複合中的每個後端個別設定 Proxy 設定。如果使用的網路需要針對 HTTP 和 HTTPS URL 使用不同的 Proxy 伺服器,您可以為單一後端同時設定 HTTP 和 HTTPS Proxy 設定:在這種情況下,http 存取將使用 http Proxy,而 https 存取將使用 https Proxy。此外,您可以使用應用程式和 Proxy 之間的 Proxy 定義協定,指定單一 Proxy 以用於兩種協定。

下表描述 HTTP 和 HTTPS Proxy 的 Proxy 組態屬性。所有這些屬性都必須以 proxy.httpproxy.https 作為前綴。

表 1. Proxy 組態屬性
屬性名稱 備註

host

Proxy 的主機。

port

用於存取 Proxy 的 Port。

nonProxyHosts

組態伺服器應在 Proxy 之外存取的任何主機。如果同時為 proxy.http.nonProxyHostsproxy.https.nonProxyHosts 提供值,則將使用 proxy.http 值。

username

用於向 Proxy 驗證身分的使用者名稱。如果同時為 proxy.http.usernameproxy.https.username 提供值,則將使用 proxy.http 值。

password

用於向 Proxy 驗證身分的密碼。如果同時為 proxy.http.passwordproxy.https.password 提供值,則將使用 proxy.http 值。

以下組態使用 HTTPS Proxy 存取 Git 儲存庫。

spring:
  profiles:
    active: git
  cloud:
    config:
      server:
        git:
          uri: https://github.com/spring-cloud-samples/config-repo
          proxy:
            https:
              host: my-proxy.host.io
              password: myproxypassword
              port: '3128'
              username: myproxyusername
              nonProxyHosts: example.com