

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 與 Amazon DCV 連線閘道整合
<a name="configure-gateway-integration"></a>

[Amazon DCV Connection Gateway](https://docs.aws.amazon.com/dcv/latest/gw-admin/what-is-gw.html) 是一種可安裝的軟體套件，可讓使用者透過 LAN 或 VPC 的單一存取點存取 Amazon DCV 伺服器機群。

 如果您的基礎設施包含可透過 Amazon DCV Connection Gateway 存取的 Amazon DCV 伺服器，您可以設定 Session Manager 來整合 Amazon DCV Connection Gateway。透過遵循下節中概述的步驟，代理程式將充當 Connection Gateway [的工作階段解析程式](https://docs.aws.amazon.com/dcv/latest/gw-admin/session-resolver.html)。換句話說，代理程式會公開額外的 HTTP 端點。Connection Gateway 將對端點進行 API 呼叫，以擷取將 Amazon DCV 連線路由至代理程式選取的主機所需的資訊。

**Topics**
+ [將 Session Manager Broker 設定為 Amazon DCV Connection Gateway 的工作階段解析程式](#set-up-sm-broker)
+ [選用 - 啟用 TLS 用戶端身分驗證](#enable-tls-client-auth)
+ [Amazon DCV 伺服器 - DNS 映射參考](dcv-server-dns-mapping.md)

## 將 Session Manager Broker 設定為 Amazon DCV Connection Gateway 的工作階段解析程式
<a name="set-up-sm-broker"></a>

**Session Manager 中介裝置端**

1. `/etc/dcv-session-manager-broker/session-manager-broker.properties` 使用您偏好的文字編輯器開啟 ，並套用下列變更：
   + 設定 `enable-gateway = true`
   + `gateway-to-broker-connector-https-port` 設定為可用的 TCP 連接埠 （預設為 8447)
   + `gateway-to-broker-connector-bind-host` 設定為代理程式為 Amazon DCV Connection Gateway 連線繫結的主機 IP 地址 （預設為 0.0.0.0) 

1. 然後執行下列命令來停止和重新啟動中介裝置：

   ```
   sudo systemctl stop dcv-session-manager-broker
   ```

   ```
   sudo systemctl start dcv-session-manager-broker
   ```

1. 擷取代理程式自我簽署憑證的副本，並將其放在您的使用者目錄中。

   ```
   sudo cp /var/lib/dcvsmbroker/security/dcvsmbroker_ca.pem $HOME
   ```

   在下一個步驟中安裝 Amazon DCV Connection Gateway 時會需要它。

**Amazon DCV Connection Gateway 端**
+ 請遵循 Amazon DCV Connection Gateway 文件中的 [一節](https://docs.aws.amazon.com/dcv/latest/gw-admin/setting-up-configuring.html#configuring-resolver)。

  由於 Amazon DCV Connection Gateway 會對代理程式進行 HTTP API 呼叫，如果代理程式使用自我簽署憑證，您將需要將代理程式憑證複製到 Amazon DCV Connection Gateway 主機 （在上一個步驟中擷取），並在 Amazon DCV Connection Gateway 組態的 `[resolver]`區段中設定 `ca-file` 參數。

## 選用 - 啟用 TLS 用戶端身分驗證
<a name="enable-tls-client-auth"></a>

完成上一個步驟後，Session Manager 和 Connection Gateway 可以透過安全頻道進行通訊，連線閘道可以驗證 Session Manager Brokers 的身分。如果您需要 Session Manager Brokers 在建立安全頻道之前驗證 Connection Gateway 的身分，則需要按照下一節中的步驟啟用 TLS 用戶端身分驗證功能。

**注意**  
如果 Session Manager 位於負載平衡器後方，則無法使用具有 TLS 連線終止的負載平衡器啟用 TLS 用戶端身分驗證，例如 Application Load Balancer (ALBs) 或 Gateway Load Balancer (GLBs)。僅支援沒有 TLS 終止的負載平衡器，例如 Network Load Balancer (NLBs)。如果您使用 ALBs 或 GLBs，您可以強制執行只有特定安全群組可以聯絡負載平衡器，確保額外的安全層級；此處的安全群組詳細資訊：[VPC 的安全群組](https://docs.aws.amazon.com/vpc/latest/userguide/VPC_SecurityGroups.html) 

**Session Manager 中介裝置端**

1. 若要啟用 Session Manager Brokers 與 Amazon DCV Connection Gateway 之間通訊的 TLS 用戶端身分驗證，請遵循下列步驟：

1.  透過執行 來產生所需的金鑰和憑證： 命令的輸出會告訴您產生登入資料的資料夾，以及用於建立 TrustStore 檔案的密碼。

   ```
   sudo /usr/share/dcv-session-manager-broker/bin/gen-gateway-certificates.sh
   ```

1.  將 Amazon DCV Connection Gateway 的私有金鑰和自我簽署憑證的副本放在您的使用者目錄中。在下一個步驟中，當您在 Amazon DCV Connection Gateway 中啟用 TLS 用戶端身分驗證時，將會需要它。

   ```
   sudo cp /etc/dcv-session-manager-broker/resolver-creds/dcv_gateway_key.pem $HOME 
   ```

   ```
   sudo cp /etc/dcv-session-manager-broker/resolver-creds/dcv_gateway_cert.pem $HOME
   ```

1.  然後使用您偏好的文字編輯器開啟 /etc/dcv-session-manager-broker/session-manager-broker.properties，並執行下列動作：
   + 將 `enable-tls-client-auth-gateway` 設定為 `true`
   + `gateway-to-broker-connector-trust-store-file` 設定為在上一個步驟中建立的 TrustStore 檔案路徑
   + 將 `gateway-to-broker-connector-trust-store-pass`設定為用於在上一個步驟中建立 TrustStore 檔案的密碼

1. 然後執行下列命令來停止並重新啟動中介裝置：

   ```
   sudo systemctl stop dcv-session-manager-broker
   ```

   ```
   sudo systemctl start dcv-session-manager-broker
   ```

**Amazon DCV Connection Gateway 端**
+ 請遵循 Amazon DCV Connection Gateway 文件中的 [一節](https://docs.aws.amazon.com/dcv/latest/gw-admin/setting-up-configuring.html)。
  + 在 `[resolver]`區段中設定 `cert-file` 參數時，使用您在上一個步驟中複製的憑證檔案的完整路徑
  + 在 `[resolver]`區段中設定 `cert-key-file` 參數時，使用您在上一個步驟中複製之金鑰檔案的完整路徑

# Amazon DCV Session Manager Amazon DCV 伺服器 - DNS 映射參考
<a name="dcv-server-dns-mapping"></a>

 Amazon DCV Connection Gateway 需要 Amazon DCV 伺服器的 DNS 名稱，才能連線至 DCV 伺服器執行個體。本節說明如何定義 JSON 檔案，其中包含每個 DCV 伺服器與其相關聯 DNS 名稱之間的映射。

## 檔案結構
<a name="file-structure"></a>

映射包含具有下列欄位的 JSON 物件清單：

```
[
	{
		“ServerIdType”: "Ip",
		“ServerId”: "192.168.0.1",
		“DnsNames”:
		{
			“InternalDnsName”: "internal"
		}
	},
	...
]
```

其中：

**`ServerIdType: `**  
識別值所指的 ID 類型；目前可用的值為 ipAddress、agentServerId 和 instanceId：    
**`Ip: `**  
適用於 Amazon EC2 和內部部署基礎設施；系統管理員可以使用 ifconfig (Linux/macOS) 或 ipconfig (Windows) 命令快速擷取。此資訊也可在 DescribeServers API 回應中使用。  
**`Id: `**  
適用於 Amazon EC2 和內部部署基礎設施；每次主機名稱或 IP 地址變更時，Session Manager Agent 都會建立新的 UUID。此資訊可在 DescribeServers API 回應中使用。  
**`Host.Aws.Ec2InstanceId: `**  
僅適用於 Amazon EC2 執行個體，它可唯一識別機器，執行個體重新啟動後不會變更。可透過聯絡 https：//http://169.254.169.254/latest/meta-data/instance-id 在主機上擷取。此資訊也可在 DescribeServers API 回應中使用。

**`ServerId: `**  
指定類型的 ID，可唯一識別網路中的每個 Amazon DCV 伺服器。

**`DnsNames: `**  
包含與此物件之 Amazon DCV 伺服器相關聯之 DNS 名稱的物件將包含：    
**`InternalDnsNames: `**  
Amazon DCV Connection Gateway 用來連線至執行個體的 DNS 名稱。

請使用 Session Manager Broker CLI 命令從檔案`register-server-dns-mapping`載入映射 （命令頁面參考： [register-server-dns-mapping](https://docs.aws.amazon.com/dcv/latest/sm-admin/register-server-dns-mappings.html))`describe-server-dns-mappings`，並列出 Session Manager Broker 中目前載入的映射 （命令頁面參考： [describe-server-dns-mappings](https://docs.aws.amazon.com/dcv/latest/sm-admin/describe-server-dns-mappings.html))。

## Persistence
<a name="persistence"></a>

我們強烈建議您啟用 Session Manager Broker 的持久性功能，以便在多個代理程式或整個叢集停機時防止映射遺失。如需啟用資料持久性的詳細資訊，請參閱[設定中介裝置持久性](https://docs.aws.amazon.com/dcv/latest/sm-admin/configure_broker_persistence.html) 