We use Apigee X and have a custom domain setup for our Integrated Portal (using these instructions). I have things setup so non http requests are redirected to https, and requests with www (either http or https) are redirected to the https non-www domain.
I noticed recently that when the load balancer responds with a HTTP 301 redirect, the URL in the location header and in the response body appends ":443" to end the URL. Of course, it functions all the same, and Chrome at least removes that port from the address bar, so no harm. But I am curious why the load balancer started doing this. We haven't made any changes to this configuration but it seems like the load balancer started appending the port number at some point.
In any case, does anyone know if it's possible to remove the port number from the URL sent back with the redirect response?
Here's a snippet of the terraform we use to configure this:
variable "developer_portal_hostname" {
type = string
description = "Developer portal hostname."
default = "developer.example.com"
}
variable "backend_integrated_portal_hostname" {
type = string
description = "Default hostname for Apigee integrated portal. https://cloud.google.com/apigee/docs/api-platform/publish/portal/custom-domain#default-host"
default = "example.apigee.io"
}
resource "google_compute_global_network_endpoint_group" "this" {
name = "apigee-developer-portal"
network_endpoint_type = "INTERNET_FQDN_PORT"
}
resource "google_compute_global_network_endpoint" "this" {
global_network_endpoint_group = google_compute_global_network_endpoint_group.this.name
port = 0
fqdn = var.backend_integrated_portal_hostname
}
resource "google_compute_backend_service" "this" {
provider = google-beta
name = "apigee-developer-portal"
protocol = "HTTPS"
backend {
group = google_compute_global_network_endpoint_group.this.id
}
}
resource "google_compute_global_address" "this" {
name = "apigee-developer-portal"
ip_version = "IPV4"
address_type = "EXTERNAL"
}
resource "google_compute_global_forwarding_rule" "https" {
provider = google-beta
name = "apigee-developer-portal"
target = google_compute_target_https_proxy.https.id
ip_address = google_compute_global_address.this.address
port_range = "443"
}
resource "google_compute_url_map" "https" {
name = "apigee-developer-portal"
default_service = google_compute_backend_service.this.id
host_rule {
hosts = ["www.${var.developer_portal_hostname}"]
path_matcher = "www"
}
path_matcher {
name = "www"
default_url_redirect {
host_redirect = var.developer_portal_hostname
https_redirect = true
redirect_response_code = "MOVED_PERMANENTLY_DEFAULT"
strip_query = false
}
}
default_route_action {
url_rewrite {
host_rewrite = var.backend_integrated_portal_hostname
}
}
}
resource "google_compute_target_https_proxy" "https" {
name = "apigee-developer-portal"
url_map = google_compute_url_map.https.id
ssl_certificates = [google_compute_managed_ssl_certificate.this.id]
}
resource "google_compute_global_forwarding_rule" "http" {
provider = google-beta
name = "apigee-developer-portal-non-tls"
target = google_compute_target_http_proxy.http.id
ip_address = google_compute_global_address.this.address
port_range = "80"
}
resource "google_compute_target_http_proxy" "http" {
name = "apigee-developer-portal-non-tls"
url_map = google_compute_url_map.http.id
}
resource "google_compute_url_map" "http" {
name = "apigee-developer-portal-non-tls"
# Redirect all non-https requests to https.
default_url_redirect {
host_redirect = var.developer_portal_hostname
https_redirect = true
redirect_response_code = "MOVED_PERMANENTLY_DEFAULT"
strip_query = false
}
}
resource "google_compute_managed_ssl_certificate" "this" {
name = "apigee-developer-portal"
managed {
domains = [
var.developer_portal_hostname,
"www.${var.developer_portal_hostname}"
]
}
}