GardenCloud & systems

Point a short hostname at a canonical destination

An older Nginx redirect fragment, with DNS, redirect response, and HTTPS validation separated.

The earlier note used a DNS A record and an Nginx virtual host to turn a short hostname into a fixed redirect. DNS sends the request to a server; Nginx returns the destination URL.

# Create domain config
sudo -s
cat << 'EOF' > /etc/nginx/sites-available/short.example.com
server {
    listen 80;
    listen [::]:80;


    server_name short.example.com;
    rewrite ^/(.*)$ https://www.example.com/destination permanent;
}
EOF

# Register domain
sudo ln -s /etc/nginx/sites-available/short.example.com /etc/nginx/sites-enabled/
sudo nginx -t
sudo service nginx reload

# Setup ssl
sudo certbot --nginx

The source’s meeting hostname and personal scheduling URL have been replaced with example names. Its rewrite sends matched paths to one fixed destination rather than appending the captured path. Query-string handling still needs an explicit expectation and check.

A permanent redirect can be cached, so the selected destination and status should be deliberate. The HTTP listener and subsequent Certbot command are separate stages; an accepted Nginx configuration does not prove the correct certificate or HTTPS response is active.

For a real redirect, inspect the response status and Location for the intended HTTP/HTTPS URLs. No DNS record, server configuration, certificate, or scheduling service was changed here.

← Back to the garden