With a simple context file (eg templates/redirect.yaml), have a mapping of names (foo) to redirect URLs (https://foo.com/hacksoc). This would be useful for having branded, memorable links for services like Discord invites, mailing list Google Form, etc.
Implementation
Here are two ways this could be implemented:
1.
A mapping foo to https://foo.com/hacksoc generates a file called foo, with the contents
<html>
<head>
<meta http-equiv="refresh" content="0;URL='https://foo.com/hacksoc'" />
</head>
<body>
<p>You are being redirected to <a href="https://foo.com/hacksoc">https://foo.com/hacksoc</a></p>
</body>
</html>
Correct operation depends on nginx serving extension-less files as text/html – if needed redirects could be served under hacksoc.org/redir/foo (for example), and then Content-type rules could be applied to the /redir/ path.
2. HTTP 302
A mapping foo to https://foo.com/hacksoc generates a nginx config block, with the contents
Idea
With a simple context file (eg
templates/redirect.yaml
), have a mapping of names (foo
) to redirect URLs (https://foo.com/hacksoc
). This would be useful for having branded, memorable links for services like Discord invites, mailing list Google Form, etc.Implementation
Here are two ways this could be implemented:
1.
A mapping
foo
tohttps://foo.com/hacksoc
generates a file calledfoo
, with the contentsCorrect operation depends on nginx serving extension-less files as text/html – if needed redirects could be served under
hacksoc.org/redir/foo
(for example), and then Content-type rules could be applied to the/redir/
path.2. HTTP 302
A mapping
foo
tohttps://foo.com/hacksoc
generates a nginx config block, with the contentsAll of the nginx config blocks are written to
redirect.conf
, which is placed somewhere outside of the webroot.include /path/to/redirect.conf;
in an appropriate placesystemctl reload nginx
ornginx -s reload