- Purpose: The backend bucket is where your static files (e.g., images, CSS, etc.) are stored.
- Command:
gcloud compute backend-buckets create origin-cdn-store \ --gcs-bucket-name=your-gcs-bucket-name
- What it does: This creates a backend bucket named
origin-cdn-store
, which is linked to a Google Cloud Storage (GCS) bucket where your content is hosted.
- Purpose: The URL map defines how traffic should be routed based on URL patterns or hostnames.
- Command:
gcloud compute url-maps create store-url-map-prd \ --default-backend-bucket=origin-cdn-store
- What it does: This creates a URL map called
store-url-map-prd
. Any traffic not explicitly matched by a specific rule will be routed to theorigin-cdn-store
backend bucket by default.
- Purpose: To route traffic based on specific hostnames (like
cdn.store.com.br
) and paths (like/images/*
). - Command:
gcloud compute url-maps add-path-matcher store-url-map-prd \ --default-backend-bucket=origin-cdn-store \ --path-matcher-name=cdn-rules \ --new-hosts=cdn.store.com.br \ --path-rules="/=origin-cdn-store,/images/*=origin-cdn-store"
- What it does:
- Adds a path matcher named
cdn-rules
to the URL map. - Routes all traffic from the domain
cdn.store.com.br
to the backend bucketorigin-cdn-store
. - Specifies that both the root path (
/
) and any paths under/images/
should also be routed toorigin-cdn-store
.
- Adds a path matcher named
- Purpose: To ensure that your URL map was created correctly and routes are set up.
- Command:
gcloud compute url-maps describe store-url-map-prd
- What it does: This shows the configuration of your URL map, including the host rules and path matchers you've set up.
- Purpose: The proxy handles HTTPS traffic and links the URL map with your SSL certificate.
- Command:
gcloud compute target-https-proxies create store-https-proxy-prd \ --url-map=store-url-map-prd \ --ssl-certificates=store-prd-cert
- What it does: This creates an HTTPS proxy (
store-https-proxy-prd
) that secures the connection usingstore-prd-cert
and routes traffic according to the rules in the URL map (store-url-map-prd
).
- Purpose: The forwarding rule tells Google Cloud where to send incoming traffic (to your proxy) and which IP address it should listen on.
- Command:
gcloud compute forwarding-rules create store-https-lb-forwarding-rule-prd \ --address=store-prd-lb-cdn-ip \ --global \ --target-https-proxy=store-https-proxy-prd \ --ports=443
- What it does: This creates a forwarding rule that listens for HTTPS traffic on port 443 and routes it to your HTTPS proxy. The static IP
store-prd-lb-cdn-ip
is assigned to this rule, so traffic to your domain (cdn.store.com.br
) is sent to the load balancer.
- Backend Bucket: Stores your content (
origin-cdn-store
). - URL Map: Routes traffic to the backend bucket, using rules to match specific hostnames and paths.
- HTTPS Proxy: Ensures traffic is securely routed and handles SSL certificates.
- Forwarding Rule: Directs traffic to your proxy and assigns a static IP.