Skip to content

Commit

Permalink
Alt domain redirect (#101)
Browse files Browse the repository at this point in the history
* Redirect traffic from alias to primary domain

* remove extra white line
  • Loading branch information
kkr16 committed Apr 22, 2022
1 parent d107443 commit f5dc940
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions gcping.tf
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,26 @@ resource "google_compute_url_map" "global" {
name = "global"
description = "a description"
default_service = google_compute_backend_service.global.id

// Create a host rule to match traffic to alias (gcpping.com)
host_rule {
hosts = [
var.domain_alias,
]
path_matcher = "alt-redirect"
}

// 301 redirect traffic from gcpping.com to gcping.com
path_matcher {
name = "alt-redirect"

default_url_redirect {
host_redirect = var.domain
https_redirect = false
redirect_response_code = "MOVED_PERMANENTLY_DEFAULT"
strip_query = false
}
}
}

// Create a global backend service with a backend for each regional NEG.
Expand Down

0 comments on commit f5dc940

Please sign in to comment.