目的:在GCP上建立台灣版的HTTP轉HTTPS的負載平衡器
步驟:
1. 進入GCP Console
2. 點選右上角的【啟用Cloud Shell】
3. 點選右下角【開啟編輯器】
4. 點選【File】➔【New File】
5. 貼上以下內容(相關名稱與domain請自行修改)
kind: compute#urlMap name: example-http-to-https defaultUrlRedirect: redirectResponseCode: MOVED_PERMANENTLY_DEFAULT httpsRedirect: True tests: - description: Test with no query parameters host: example.com path: / expectedOutputUrl: https://example.com/ expectedRedirectResponseCode: 301
7. 點選右上角X ➔ 離開編輯器
8. 到【VPC Network】➔【IP Address】➔尋找HTTPS負載平衡器,建立的HTTPS IP名稱。
9. 點選右上角的【啟用Cloud Shell】
10. 執行以下指令(請依自行設定的區域、IP名稱自行修改)
gcloud compute url-maps import example-http-to-https --source /tmp/web-map-http.yaml --region=asia-east1 gcloud compute url-maps describe example-http-to-https --region=asia-east1 gcloud compute target-http-proxies create http-lb-proxy --url-map=example-http-to-https --region=asia-east1 gcloud compute forwarding-rules create http-content-rule \ --load-balancing-scheme=EXTERNAL_MANAGED \ --address=uat-example-https2 \ --network-tier=STANDARD \ --region=asia-east1 \ --target-http-proxy=http-lb-proxy \ --target-http-proxy-region=asia-east1 \ --ports=80
0 意見:
張貼留言