From d8ec573bc790d3a2b96eaa9ec4185aff8ed31e48 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Fri, 9 Apr 2021 22:55:41 +0200 Subject: feat(ops/nixos/www): Enable short links for b/ and cl/ This configures accepting requests for b/ and cl/ on plain HTTP ports, and redirecting to b.tvl.fyi & cl.tvl.fyi appropriately. Additionally, Panettone request URIs that only contain decimals are redirected to `/issues/$request_uri` to enable issue short-links. This fixes b/32. Change-Id: I56954d8d69a3624267778b467520c509f4daa6c5 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2908 Tested-by: BuildkiteCI Reviewed-by: lukegb Reviewed-by: sterni --- ops/nixos/www/b.tvl.fyi.nix | 10 ++++++++++ ops/nixos/www/cl.tvl.fyi.nix | 5 +++++ 2 files changed, 15 insertions(+) (limited to 'ops/nixos/www') diff --git a/ops/nixos/www/b.tvl.fyi.nix b/ops/nixos/www/b.tvl.fyi.nix index 9bbdcd22ae..45f6c6ed51 100644 --- a/ops/nixos/www/b.tvl.fyi.nix +++ b/ops/nixos/www/b.tvl.fyi.nix @@ -6,6 +6,11 @@ ]; config = { + services.nginx.virtualHosts."b-shortlink" = { + serverName = "b"; + extraConfig = "return 302 https://b.tvl.fyi$request_uri;"; + }; + services.nginx.virtualHosts."b.tvl.fyi" = { serverName = "b.tvl.fyi"; serverAliases = [ "b.tvl.su" ]; @@ -13,6 +18,11 @@ forceSSL = true; extraConfig = '' + # Forward short links to issues to the issue itself (b/32) + location ~ ^/(\d+)$ { + return 302 https://b.tvl.fyi/issues$request_uri; + } + location / { proxy_pass http://localhost:${toString config.services.depot.panettone.port}; } diff --git a/ops/nixos/www/cl.tvl.fyi.nix b/ops/nixos/www/cl.tvl.fyi.nix index d0aac1b098..470122c395 100644 --- a/ops/nixos/www/cl.tvl.fyi.nix +++ b/ops/nixos/www/cl.tvl.fyi.nix @@ -6,6 +6,11 @@ ]; config = { + services.nginx.virtualHosts."cl-shortlink" = { + serverName = "cl"; + extraConfig = "return 302 https://cl.tvl.fyi$request_uri;"; + }; + services.nginx.virtualHosts.gerrit = { serverName = "cl.tvl.fyi"; serverAliases = [ "cl.tvl.su" ]; -- cgit 1.4.1