From 490c50179bceed35f804f771e4053f4f950b3b8b Mon Sep 17 00:00:00 2001 From: Mark Bundschuh Date: Sat, 8 Feb 2025 13:01:46 -0500 Subject: [PATCH] redirect config and docs --- README.md | 6 ++++++ traefik.tf | 20 ++++++++++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d90e0c4..0193e89 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,12 @@ This is a log of important decisions made to the infrastructure, reasoning why a decision was made, and why other options were not chosen. Minor changes, like deploying an extra container, do not necessarily need to be a part of the decisions log. However, changes to the _way_ the infrastructure works should be documented here for future generations. +### 2025-02-05: Traefik for redirects + +Use Traefik docker labels for redirects. That is, all subdomains should redirect to [osucyber.club](https://osucyber.club) if they are no used by anything else. Also, certain subdomains like [discord.osucyber.club](https://discord.osucyber.club) should go to a Discord invite link. An alternative (which was used before) was to have an API Gateway in front of a Lambda function which handles redirects. However, this introduces more complexity and adds more resources added to Terraform. Using Traefik is more native since we already have it, and it requires only a small amount of configuration. Though, if Traefik is down, the redirects will stop working. Both options are free of cost, we choose the most minimal option. + +First introduced in [77d1d881](https://github.com/cscosu/infra2/commit/77d1d8816cf29184120fc5c5df5193bd379b3052). + ### 2025-02-02: Minimize root disk space Use minimal AMI instead of ECS optimized AMI. The ECS optimized AMI requires a minimum of a 30GB root volume, however we really only need a 4GB root volume. At $0.08/GB/month, this means $2.08/instance/month saved. The ECS agent cleans up old images every 30 minutes by default ([docs](https://github.com/aws/amazon-ecs-agent/blob/0f876b5372c9ecb15228f607f11d2c4be629d364/README.md#L206)), so there is little reason to worry about running out of storage. Additionally, it is easy to change the root storage if needed by just modifying the Terraform. This comes at a maintenance cost of additional user data script to install the required agents, though this should be just copy/paste. diff --git a/traefik.tf b/traefik.tf index 30f9d84..6960b37 100644 --- a/traefik.tf +++ b/traefik.tf @@ -118,10 +118,22 @@ resource "aws_ecs_task_definition" "traefik" { "traefik.http.middlewares.redirect-to-main.redirectregex.regex" = ".*" "traefik.http.middlewares.redirect-to-main.redirectregex.replacement" = "https://osucyber.club" - "traefik.http.routers.discord.rule" = "Host(`discord.testing.osucyber.club`)" - "traefik.http.routers.discord.middlewares" = "redirect-discord" - "traefik.http.middlewares.redirect-discord.redirectregex.regex" = ".*" - "traefik.http.middlewares.redirect-discord.redirectregex.replacement" = "https://discord.com" + "traefik.http.routers.discord.rule" = "Host(`discord.testing.osucyber.club`)" + "traefik.http.routers.discord.middlewares" = "redirect-discord" + "traefik.http.middlewares.redirect-discord.redirectregex.regex" = ".*" + "traefik.http.middlewares.redirect-discord.redirectregex.replacement" = "https://discord.gg/x4VgQBTBCp" + "traefik.http.routers.zoom.rule" = "Host(`zoom.testing.osucyber.club`)" + "traefik.http.routers.zoom.middlewares" = "redirect-zoom" + "traefik.http.middlewares.redirect-zoom.redirectregex.regex" = ".*" + "traefik.http.middlewares.redirect-zoom.redirectregex.replacement" = "https://osu.zoom.us/j/94385413286?pwd=L2pHUEc0blZqV0Erc3pNeWxRTW4vUT09" + "traefik.http.routers.mailinglist.rule" = "Host(`mailinglist.testing.osucyber.club`)" + "traefik.http.routers.mailinglist.middlewares" = "redirect-mailinglist" + "traefik.http.middlewares.redirect-mailinglist.redirectregex.regex" = ".*" + "traefik.http.middlewares.redirect-mailinglist.redirectregex.replacement" = "https://eepurl.com/c0qMHn" + "traefik.http.routers.attend.rule" = "Host(`attend.testing.osucyber.club`)" + "traefik.http.routers.attend.middlewares" = "redirect-attend" + "traefik.http.middlewares.redirect-attend.redirectregex.regex" = ".*" + "traefik.http.middlewares.redirect-attend.redirectregex.replacement" = "https://auth.osucyber.club" } logConfiguration = {