Cloud Secure Web Proxy (SWP) Codelab

1. 简介

Cloud 安全 Web 代理

Cloud SWP 是一项云优先服务,可提供 Secure Web Proxy,帮助您保护出站 Web 流量 (HTTP/S)。您将客户端配置为显式使用 Cloud SWP 作为代理。Web 请求可能来自以下来源:

  • 虚拟机 (VM) 实例
  • 容器
  • 使用无服务器连接器的无服务器环境
  • VPC 对等互连中的工作负载
  • 通过 Cloud VPN 或 Cloud Interconnect 连接的 Google Cloud 外部的工作负载

Cloud SWP 可以基于云优先身份和 Web 应用实现灵活、精细的政策。

优势

下面列举了一些 Cloud SWP 可为组织带来的好处:

迁移到 Google Cloud

Cloud SWP 可帮助您迁移到 Google Cloud,同时保留您针对出站 Web 流量的现有安全政策和要求。您可以避免使用需要其他管理控制台或手动修改配置文件的第三方解决方案。

访问受信任的外部 Web 服务

借助 Cloud SWP,您可以对 Web 出站流量应用精细的访问权限政策,从而保护您的网络。您需要创建并识别工作负载或应用身份,然后应用政策。

监控对不可信 Web 服务的访问

您可以使用 Cloud SWP 来提供对不受信任的 Web 服务的受监控访问。Cloud SWP 会识别不符合政策的流量,并将其记录到 Cloud Logging(日志记录)中。然后,您可以监控互联网使用情况、发现网络威胁并应对威胁。

针对 Google API 的精细政策控件

您可以使用 Cloud SWP 为 Google API 提供精细的政策。例如,您可以利用通用表达式语言 (CEL) 设置存储分区/对象级政策。

支持的功能

Cloud SWP 支持以下功能:

显式代理服务

必须明确配置客户端以使用代理服务器。Cloud SWP 代理会代表客户端创建新的 TCP 连接,从而将客户端与互联网隔离开。

自动扩缩 Cloud SWP Envoy 代理

支持自动调整区域中的 Envoy 代理池大小和池容量,从而以最低的成本在需求高峰期实现稳定的性能。

模块化出站流量访问权限政策

Cloud SWP 专门支持以下出站流量政策:

  • 基于安全标记、服务账号或 IP 地址的来源身份。
  • 基于网址、主机名的目的地。
  • 基于方法、标头或网址的请求。您可以使用列表、通配符或格式指定网址。
  • 端到端加密:客户端-代理隧道可能会通过 TLS 进行传输。Cloud SWP 还支持 HTTP/S CONNECT,以便建立由客户端发起的与目标服务器的端到端 TLS 连接。

简化的 Cloud NAT 集成

当提供 Cloud SWP 流量的代理数量增加时,Cloud NAT 会自动预配额外的公共 IP 地址。

对于希望拥有已知出站 IP 的用户,手动静态公共 IP 地址也是一种选择。

Cloud Audit Logs 与 Google Cloud 的运维套件集成

Cloud Audit Logs 和 Google Cloud 的运维套件会记录与 Cloud SWP 相关的资源的管理活动和访问请求。它们还会记录代理处理的请求的指标和交易日志。

TLS 检查

Secure Web Proxy 提供 TLS 检查服务,让您可以拦截 TLS 流量、检查加密请求并强制执行安全政策。

  • Certificate Authority Service (CAS) 紧密集成,后者是一个高可用且可扩缩的私有 CA 存储库。
  • 能够根据需要使用自己的信任根。您还可以使用现有根 CA 为 CAS 持有的从属 CA 进行签名。您也可以在 CAS 中生成新的根证书。
  • 在 Secure Web Proxy 政策规则中使用 SessionMatcher 和 ApplicationMatcher 实现精细的解密条件。此条件包括网址列表、正则表达式、IP 地址范围和类似表达式中存在的匹配主机。如有需要,可使用布尔表达式组合条件。
  • 每个 Secure Web Proxy 政策都可以配置自己的 TLS 检查政策和 CA 池。或者,多个 Secure Web Proxy 政策可以共用一个 TLS 检查政策。

学习内容

  • 如何部署和管理 Cloud SWP。

所需条件

  • 了解如何部署实例和配置网络组件
  • VPC 防火墙配置知识

2. 测试环境

此 Codelab 将利用单个 VPC。此环境中的计算资源将使用 Cloud SWP 出站,如下图所示。

1264e30caa136365.png

在本实验中,我们将有 2 个工作负载虚拟机。

客户端 A 将配置为将所有 HTTP/HTTPS 请求发送到 Cloud SWP。

客户端 B不会配置为明确向 Cloud SWP 发送 HTTP/HTTPS 请求,而是利用 Cloud NAT 处理出站互联网流量。

3. 准备工作

Codelab 需要单个项目。

在 Cloud Shell 中,确保项目 ID 已设置

export project_id=`gcloud config list --format="value(core.project)"`
export project_number=`gcloud projects describe $project_id --format="value(projectNumber)"`
export region=us-west1
export zone=us-west1-a
export prefix=codelab-swp
export member="serviceAccount:service-$project_number@gcp-sa-networksecurity.iam.gserviceaccount.com"

4. 启用 API

启用 API 以使用产品

gcloud services enable networksecurity.googleapis.com
gcloud services enable certificatemanager.googleapis.com
gcloud services enable networkservices.googleapis.com

5. 创建 VPC 网络、子网和代理专用子网

VPC 网络

创建 codelab-swp-vpc VPC

gcloud compute networks create $prefix-vpc --subnet-mode=custom 

子网

在所选区域中创建相应的子网:

gcloud compute networks subnets create $prefix-vpc-subnet \
   --range=10.10.10.0/24 --network=$prefix-vpc --region=$region

代理专用子网

在所选区域中创建代理专用子网:

gcloud compute networks subnets create $prefix-proxy-only-subnet --purpose=REGIONAL_MANAGED_PROXY --role=ACTIVE --region=$region --network=$prefix-vpc --range=172.16.0.0/23

6. 创建防火墙规则

如需允许 IAP 连接到您的虚拟机实例,请创建一个防火墙规则,该规则应:

  • 适用于您希望使用 IAP 可访问的所有虚拟机实例。
  • 允许来自 IP 范围 35.235.240.0/20 的入站流量。此范围包含 IAP 用于 TCP 转发的所有 IP 地址。

在 Cloud Shell 中:

gcloud compute firewall-rules create $prefix-allow-iap-proxy \
--direction=INGRESS \
--priority=1000 \
--network=$prefix-vpc \
--action=ALLOW \
--rules=tcp:22 \
--source-ranges=35.235.240.0/20

7. 创建 Cloud Router 和 Cloud NAT

为 Cloud NAT 创建 Cloud Router。

gcloud compute routers create ${prefix}-cr \
--region=$region \
--network=${prefix}-vpc

为客户端 B 创建 Cloud NAT 网关。

gcloud compute routers nats create $prefix-nat-gw-$region \
--router=$prefix-cr \
--router-region=$region \
--auto-allocate-nat-external-ips \
--nat-all-subnet-ip-ranges

8. 创建网关安全政策

创建一个包含政策相关信息的 YAML 文件:

cat > /tmp/policy.yaml << EOF
description: Policy to allow .com traffic, then (/index.html), and finally TLS.
name: projects/${project_id}/locations/${region}/gatewaySecurityPolicies/${prefix}-policy
EOF

运行 gcloud 命令,根据 YAML 文件创建政策:

gcloud network-security gateway-security-policies import ${prefix}-policy --source=/tmp/policy.yaml --location=${region}

9. 创建网关安全政策规则

创建一个包含规则的 YAML 文件。这些规则以通用表达式语言 (CEL) 表示。本实验将使用一条简单规则,该规则允许流量流向 .com 网域,并阻止所有其他流量:

cat > /tmp/rule-com.yaml << EOF
name: projects/${project_id}/locations/${region}/gatewaySecurityPolicies/${prefix}-policy/rules/rule-com
enabled: true
priority: 1
description: Allow .com traffic
basicProfile: ALLOW
sessionMatcher: host().endsWith('com')
EOF

现在,我们可以将规则绑定到网关安全政策:

gcloud network-security gateway-security-policies rules import rule-com --source=/tmp/rule-com.yaml --location=${region} --gateway-security-policy=${prefix}-policy

10. 创建证书并上传到 Cloud Certificate Manager

创建用于终止工作负载流量的证书:

openssl req -x509 -newkey rsa:2048 -keyout /tmp/key.pem -out /tmp/cert.pem -days 365 -subj '/CN=www.codelab-swp.com' -nodes -addext \
  "subjectAltName = DNS:www.codelab-swp.com"

将证书上传到 Cloud Certificate Manager,以便 SWP 可以在安全网关政策中引用该证书。

gcloud certificate-manager certificates create ${prefix}-cert --location=${region} --private-key-file=/tmp/key.pem --certificate-file=/tmp/cert.pem

11. 创建 SWP 网关

为 SWP 网关创建 YAML 文件,以引用证书、网关安全政策、网络和子网等先前的信息。

cat > /tmp/gateway.yaml << EOF
name: projects/${project_id}/locations/${region}/gateways/${prefix}-gateway
type: SECURE_WEB_GATEWAY
addresses: [10.10.10.50]
ports: [443]
certificateUrls: [projects/${project_id}/locations/${region}/certificates/${prefix}-cert]
gatewaySecurityPolicy: projects/${project_id}/locations/${region}/gatewaySecurityPolicies/${prefix}-policy
network: projects/${project_id}/global/networks/${prefix}-vpc
subnetwork: projects/${project_id}/regions/${region}/subnetworks/${prefix}-vpc-subnet
EOF

创建网关:

gcloud network-services gateways import ${prefix}-swp --source=/tmp/gateway.yaml --location=${region}

确认网关已创建:

gcloud network-services gateways describe ${prefix}-swp --location ${region}

12. 创建 Compute 实例

由于 Cloud SWP 是显式代理,因此我们需要为工作负载流量显式指定代理 IP。计算实例 clientA 将设置环境变量。但 ClientB 不会。

创建计算实例 ClientA 和 ClientB:

gcloud compute instances create clienta \
   --subnet=$prefix-vpc-subnet \
   --no-address \
   --private-network-ip=10.10.10.10 \
   --zone $zone \
   --metadata startup-script='#! /bin/bash
apt-get update
sudo echo http_proxy=https://10.10.10.50:443/ >> /etc/environment
sudo echo https_proxy=https://10.10.10.50:443/ >> /etc/environment
'
gcloud compute instances create clientb \
   --subnet=$prefix-vpc-subnet \
   --no-address \
   --private-network-ip=10.10.10.200 \
   --zone $zone \
   --metadata startup-script='#! /bin/bash
apt-get update
'

13. 测试会话匹配

通过 SSH 连接到最近创建的“clienta”Compute Engine 虚拟机。此虚拟机已设置环境变量以使用 Cloud SWP。

在 Cloud Shell 中:

gcloud compute ssh clienta --zone=$zone --tunnel-through-iap

运行一些网络查询来验证功能。我们需要使用 -proxy-insecure,因为我们为本实验创建了自签名证书:

curl https://google.com --proxy-insecure

预期输出:

davidtu@clienta:~$ curl https://google.com --proxy-insecure
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="https://www.google.com/">here</A>.
</BODY></HTML>

如图所示,请求已“成功”。由于该网站会重定向到 https://www.google.com,因此我们预计会看到 301 重定向。

运行以下命令会提供详细的连接日志:

curl https://google.com --proxy-insecure -v

突出显示了一些输出,以显示代理连接详细信息、证书和目标。

davidtu@clienta:~$ curl https://google.com --proxy-insecure -v
* Uses proxy env variable https_proxy == 'https://10.10.10.50:443/'
*   Trying 10.10.10.50:443...
* Connected to 10.10.10.50 (10.10.10.50) port 443 (#0)
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*  CAfile: /etc/ssl/certs/ca-certificates.crt
*  CApath: /etc/ssl/certs
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
* TLSv1.3 (IN), TLS handshake, Certificate (11):
* TLSv1.3 (IN), TLS handshake, CERT verify (15):
* TLSv1.3 (IN), TLS handshake, Finished (20):
* TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.3 (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
* ALPN, server accepted to use http/1.1
* Proxy certificate:
*  subject: CN=www.codelab-swp.com
*  start date: Dec 12 17:16:35 2022 GMT
*  expire date: Dec 12 17:16:35 2023 GMT
*  issuer: CN=www.codelab-swp.com
*  SSL certificate verify result: self signed certificate (18), continuing anyway.
* allocate connect buffer!
* Establish HTTP proxy tunnel to google.com:443
> CONNECT google.com:443 HTTP/1.1
> Host: google.com:443
> User-Agent: curl/7.74.0
> Proxy-Connection: Keep-Alive
> 
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
< HTTP/1.1 200 OK
< date: Mon, 12 Dec 2022 19:22:04 GMT
< 
* Proxy replied 200 to CONNECT request
* CONNECT phase completed!
...

您可以随意尝试其他 .com 网域来验证功能。

现在,我们尝试使用一些其他非 .com 网域来验证默认屏蔽行为:

curl https://wikipedia.org --proxy-insecure

预期输出:

curl: (56) Received HTTP code 403 from proxy after CONNECT

同样,查看详细的输出日志记录,并确认 Cloud SWP 是否正在阻止此流量:

curl https://wikipedia.org --proxy-insecure -v
davidtu@clienta:~$ curl https://wikipedia.org --proxy-insecure -v
* Uses proxy env variable https_proxy == 'https://10.10.10.50:443/'
*   Trying 10.10.10.50:443...
* Connected to 10.10.10.50 (10.10.10.50) port 443 (#0)
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*  CAfile: /etc/ssl/certs/ca-certificates.crt
*  CApath: /etc/ssl/certs
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
* TLSv1.3 (IN), TLS handshake, Certificate (11):
* TLSv1.3 (IN), TLS handshake, CERT verify (15):
* TLSv1.3 (IN), TLS handshake, Finished (20):
* TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.3 (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
* ALPN, server accepted to use http/1.1
* Proxy certificate:
*  subject: CN=www.codelab-swp.com
*  start date: Dec 12 17:16:35 2022 GMT
*  expire date: Dec 12 17:16:35 2023 GMT
*  issuer: CN=www.codelab-swp.com
*  SSL certificate verify result: self signed certificate (18), continuing anyway.
* allocate connect buffer!
* Establish HTTP proxy tunnel to wikipedia.org:443
> CONNECT wikipedia.org:443 HTTP/1.1
> Host: wikipedia.org:443
> User-Agent: curl/7.74.0
> Proxy-Connection: Keep-Alive
> 
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
< HTTP/1.1 403 Forbidden
< content-length: 13
< content-type: text/plain
< date: Mon, 12 Dec 2022 19:35:09 GMT
< connection: close
< 
* Received HTTP code 403 from proxy after CONNECT
* CONNECT phase completed!
* Closing connection 0
curl: (56) Received HTTP code 403 from proxy after CONNECT

您也可以随意尝试其他网域,以验证行为。

退出与“clienta”的 SSH 会话,并启动与“clientb”的新 SSH 连接。

gcloud compute ssh clientb --zone=$zone --tunnel-through-iap

运行一些 curl 命令来检查行为:

curl https://google.com

这应该会按预期运行 clientb 虚拟机:

davidtu@clientb:~$ curl https://google.com
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="https://www.google.com/">here</A>.
</BODY></HTML>

针对 .org 网域进行测试:

curl https://wikipedia.org

这是预期行为,因为 clientb 未利用 Cloud SWP:

davidtu@clientb:~$ curl https://wikipedia.org
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="https://www.wikipedia.org/">here</a>.</p>
</body></html>

测试通过 Cloud SWP 显式发送流量:

curl -x https://10.10.10.50:443/ https://wikipedia.org --proxy-insecure 

我们看到,此流量因 Cloud SWP 政策而被拒绝:

davidtu@clientb:~$ curl -x https://10.10.10.50:443/ https://wikipedia.org --proxy-insecure
curl: (56) Received HTTP code 403 from proxy after CONNECT

正如您所验证的那样,利用 Cloud SWP 的流量会根据配置的安全政策强制执行。允许前往 .com 的流量,拒绝前往所有其他目的地的流量。

从 clientb 退出。

14. 更新了 ApplicationMatching 的网关安全政策规则

让我们更新规则,以匹配应用级详细信息。我们将构建一条规则来检查请求路径,并且仅当请求路径与 index.html 匹配时才允许该请求。

cat > /tmp/rule-com.yaml << EOF
name: projects/${project_id}/locations/${region}/gatewaySecurityPolicies/${prefix}-policy/rules/rule-com
enabled: true
priority: 1
description: Allow .com traffic with path index.html
basicProfile: ALLOW
sessionMatcher: host().endsWith('com')
applicationMatcher: request.path.matches('index.html')
EOF

现在,我们可以将更新后的规则绑定到网关安全政策:

gcloud network-security gateway-security-policies rules import rule-com --source=/tmp/rule-com.yaml --location=${region} --gateway-security-policy=${prefix}-policy

15. 测试 ApplicationMatcher 规则

通过 SSH 连接到 clienta 计算虚拟机。此虚拟机已设置环境变量以使用 Cloud SWP。

在 Cloud Shell 中:

gcloud compute ssh clienta --zone=$zone --tunnel-through-iap

运行一些网络查询来验证功能。我们需要使用 -proxy-insecure,因为我们为本实验创建了自签名证书:

curl http://google.com --proxy-insecure

请注意,此查询之前通过了,但现在会失败。

Access denied

除了“index.html”之外的任何请求路径都应被屏蔽并返回 403 错误。您可以随意进一步测试。

修改查询以添加路径 /index.html

curl http://google.com/index.html --proxy-insecure

此请求应会成功:

davidtu@clienta:~$ curl http://google.com/index.html --proxy-insecure
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="https://www.google.com/index.html">here</A>.
</BODY></HTML>

由于网站重定向到 http://www.google.com/index.html,因此我们预计会看到 301 重定向

请注意,这是一个 HTTP 请求。接下来,您需要启用 SWP 以获得 TLS 检查功能。

接下来,运行相同的查询,但通过 TLS 进行:

curl -k https://google.com/index.html --proxy-insecure

预期输出:

curl: (56) Received HTTP code 403 from proxy after CONNECT

此请求应失败,因为 SWP 未配置为检查 TLS,无法根据 applicationMatcher 规则评估路径。

退出 clenta。

16. 启用 TLS 检查

如果不进行 TLS 检查,applicationMatcher 将无法匹配 HTTPS 流量。

“applicationMatcher”允许按以下条件进行过滤:

  • 请求标头映射
  • 请求方法
  • 请求主机
  • 请求路径
  • 请求查询
  • 请求协议
  • 完整请求网址
  • 请求用户代理

创建服务账号

此服务账号将有权为 SWP TLS 检查生成证书。

gcloud beta services identity create \
    --service=networksecurity.googleapis.com \
    --project=$project_id

确保已启用 CAS

gcloud services enable privateca.googleapis.com

创建 CA 池

gcloud privateca pools create $prefix-ca-pool \
    --tier=devops \
    --project=$project_id \
    --location=$region 

创建根 CA

用于证书签名的 CA。

gcloud privateca roots create $prefix-root-ca --pool=$prefix-ca-pool \
  --location=$region \
  --auto-enable \
  --subject="CN=my-swp-ca, O=SWP LLC"

创建证书颁发政策文件

cat > /tmp/tls-issuance-policy.yaml << EOF
maximumLifetime: 1209600s
baselineValues:
  caOptions:
    isCa: false
  keyUsage:
    extendedKeyUsage:
      serverAuth: true
EOF

创建 TLS 检查 YAML 文件

cat > /tmp/tls-inspection-policy.yaml << EOF
caPool: projects/$project_id/locations/$region/caPools/$prefix-ca-pool
name: projects/$project_id/locations/$region/tlsInspectionPolicies/$prefix-tls-inspection
EOF

创建 TLS 检查政策

gcloud network-security tls-inspection-policies import $prefix-tls-inspection \
    --source=/tmp/tls-inspection-policy.yaml \
    --location=$region

更新 CA 池以使用证书颁发政策

gcloud privateca pools update $prefix-ca-pool    --issuance-policy=/tmp/tls-issuance-policy.yaml --location=$region

授予权限

这样,您的服务账号就可以使用 CA 池来生成证书。

gcloud privateca pools add-iam-policy-binding $prefix-ca-pool \
    --member=$member \
    --role='roles/privateca.certificateManager' \
    --location=$region

更新了政策 YAML 以包含 TLS 检查

cat > /tmp/policy.yaml << EOF
description: some policy description
name: projects/${project_id}/locations/${region}/gatewaySecurityPolicies/${prefix}-policy
tlsInspectionPolicy: projects/${project_id}/locations/${region}/tlsInspectionPolicies/${prefix}-tls-inspection
EOF

运行命令以应用更新后的政策

gcloud network-security gateway-security-policies import ${prefix}-policy --source=/tmp/policy.yaml --location=${region}

更新规则以包含 TLS 检查

接下来,指定哪些规则应具有 TLS 检查“enabtlsInspectionEnabled: true”标志。

cat > /tmp/rule-com.yaml << EOF
name: projects/${project_id}/locations/${region}/gatewaySecurityPolicies/${prefix}-policy/rules/rule-com
enabled: true
priority: 1
description: Allow .com traffic with path index.html
basicProfile: ALLOW
sessionMatcher: host().endsWith('com')
applicationMatcher: request.path.matches('index.html')
tlsInspectionEnabled: true
EOF

运行命令以应用更新后的规则

gcloud network-security gateway-security-policies rules import rule-com --source=/tmp/rule-com.yaml --location=${region} --gateway-security-policy=${prefix}-policy

17. 测试 TLS 检查

通过 SSH 连接到 clienta 计算虚拟机。此虚拟机已设置环境变量以使用 Cloud SWP。

在 Cloud Shell 中:

gcloud compute ssh clienta --zone=$zone --tunnel-through-iap

运行之前的 Web 查询,验证 SWP 是否正在执行 TLS 检查以检索路径

curl -k https://google.com/index.html --proxy-insecure

这次应该会成功,因为 SWP 可以评估 ApplicationMatcher。

预期输出:

<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="https://www.google.com/index.html">here</A>.
</BODY></HTML>

我们已成功设置 Cloud SWP 来检查 TLS 并评估 applicationMatcher 逻辑!

从 clienta 退出。

18. 清理步骤

在 Cloud Shell 中,移除 SWP 网关、安全政策、证书、实例、Cloud NAT 和 Cloud Router:

gcloud -q network-services gateways delete ${prefix}-swp --location=${region}

gcloud -q network-security gateway-security-policies rules delete rule-com --location=${region} --gateway-security-policy=${prefix}-policy

gcloud -q network-security gateway-security-policies delete ${prefix}-policy --location=${region}

gcloud -q certificate-manager certificates delete ${prefix}-cert --location=${region}

gcloud -q network-security tls-inspection-policies delete $prefix-tls-inspection --location=$region

gcloud -q privateca roots disable $prefix-root-ca --pool=$prefix-ca-pool --location=$region

gcloud -q privateca roots delete $prefix-root-ca --pool=$prefix-ca-pool --location=$region --ignore-active-certificates --skip-grace-period

gcloud -q privateca pools delete $prefix-ca-pool --location=$region

gcloud -q compute instances delete clienta --zone=$zone

gcloud -q compute instances delete clientb --zone=$zone

gcloud -q compute routers nats delete ${prefix}-nat-gw-${region} \
--router=$prefix-cr --router-region=$region

gcloud -q compute routers delete `gcloud compute routers list --regions=$region --format="value(NAME)" | grep -e swg-autogen -e codelab-swp` --region=$region

移除子网、防火墙规则和 VPC:

gcloud -q compute networks subnets delete $prefix-vpc-subnet \
    --region $region

gcloud -q compute networks subnets delete $prefix-proxy-only-subnet \
    --region=$region

gcloud -q compute firewall-rules delete $prefix-allow-iap-proxy

gcloud -q compute networks delete $prefix-vpc

19. 恭喜!

恭喜您完成此 Codelab。您已成功在 Google Cloud 上配置并部署 Cloud Secure Web Proxy。

所学内容

  • Cloud SWP 及其优势!