Skip to content

Commit

Permalink
add redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
rtertiaer committed Jul 8, 2024
1 parent 67b2b14 commit 0e5d43f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `engineering-blog`

This repo generates and deploys Micro-Nova's engineering blog. Posts are stored as Markdown, rendered using [Hugo](https://gohugo.io/), and deployed to an upstream object store & CDN using GitHub Actions. Infrastructure in GCP is configured using [OpenTofu](https://opentofu.org/) and stored in `opentofu/`.
This repo generates and deploys Micro-Nova's engineering blog. Posts are stored as Markdown, rendered using [Hugo](https://gohugo.io/), and deployed to an upstream object store & CDN using GitHub Actions. Infrastructure in GCP is configured using [OpenTofu](https://opentofu.org/) and stored in `opentofu/`. We're currently using [`hugo-ficurinia`](https://gitlab.com/gabmus/hugo-ficurinia) as the theme; check out its docs too.

## How to add a blog post

Expand Down
27 changes: 27 additions & 0 deletions opentofu/lb.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
resource "google_compute_global_address" "address" {
name = "${var.project}-${var.dns_name}-${var.env}-lb"
}

resource "google_compute_backend_bucket" "backend_bucket" {
name = "${var.project}-${var.dns_name}-${var.env}" # the regex for this is restrictive
bucket_name = "${var.dns_name}.${var.dns_zone_name}"
Expand All @@ -22,4 +26,27 @@ resource "google_compute_global_forwarding_rule" "rule" {
load_balancing_scheme = "EXTERNAL_MANAGED"
ip_protocol = "TCP"
target = google_compute_target_https_proxy.lb.id
ip_address = google_compute_global_address.address.address
}

## It sure would be nice if it didn't require a full new LB to redirect from http to https.
resource "google_compute_url_map" "http_redirect" {
name = "${var.project}-${var.dns_name}-${var.env}-redirect"

default_url_redirect {
strip_query = false
https_redirect = true // this is the magic
}
}

resource "google_compute_target_http_proxy" "http_redirect" {
name = "${var.project}-${var.dns_name}-${var.env}-redirect"
url_map = google_compute_url_map.http_redirect.self_link
}

resource "google_compute_global_forwarding_rule" "http_redirect" {
name = "${var.project}-${var.dns_name}-${var.env}-redirect"
target = google_compute_target_http_proxy.http_redirect.self_link
ip_address = google_compute_global_address.address.address
port_range = "80"
}

0 comments on commit 0e5d43f

Please sign in to comment.