This site is static, so almost nothing on it can misbehave. Almost.

https://hetsulab.tech/notes (no trailing slash) answered with a 301 whose Location was http://hetsulab.tech/notes/ — plain http, from a request that arrived over https. The browser followed it, the proxy bounced it back up to https, and the page loaded fine. Which is exactly why it’s the kind of bug that sits there: the user sees a working page.

Why nginx did that

Astro builds directory-style output: /notes is notes/index.html. nginx’s try_files $uri $uri/ =404 resolves /notes to the directory, and the directory-to-slash redirect is nginx’s own 301, built from the scheme nginx believes the request used.

Behind Traefik, nginx never sees https. TLS is terminated at the proxy and the request is forwarded over plain http on port 80. nginx is not lying about the scheme — it genuinely is serving plain http on that hop. With the defaults (absolute_redirect on, server_name_in_redirect on), it writes the whole URL back out, scheme and host included, and the scheme it writes is http.

So the redirect is “correct” for the connection nginx sees, and wrong for the one the client is actually on.

The evidence

$ curl -sI https://hetsulab.tech/notes
HTTP/2 301
content-type: text/html
location: http://hetsulab.tech/notes/
server: nginx/1.31.9

server: nginx/1.31.9 matters: the 301 is coming from my container, not the proxy. And next to it, the redirect that was already right:

$ curl -sI https://www.hetsulab.tech/notes/
HTTP/2 301
location: https://hetsulab.tech/notes/
server: nginx/1.31.9

That one is the deliberate www → apex canonicalisation, where the target is written explicitly as https://hetsulab.tech$request_uri. It names its scheme, so it can’t inherit the wrong one. The trailing-slash redirect names nothing, so it inherited everything.

The fix

Two lines in nginx.conf, above everything else in the server block:

# Behind Traefik, nginx sees the request on plain http and would otherwise
# emit absolute `http://` redirects for directory-index (trailing slash).
# Relative redirects keep the client on the already-https origin.
absolute_redirect off;
server_name_in_redirect off;

absolute_redirect off is the load-bearing one: nginx emits Location: /notes/ and the client resolves it against the origin it’s already on. No scheme in the response, so no scheme to get wrong. server_name_in_redirect off is defensive — with relative redirects the host isn’t written either, but turning it off keeps a server_name mismatch from resurfacing later if someone flips absolutes back on.

That’s commit 2a681a7, six added lines, no config anywhere else. I can’t fix this at the proxy instead without teaching the proxy the site’s URL structure, and the container is the thing that knows about /notes/ and /notes/index.html. Relative was the smaller fix and it stays correct no matter what’s in front.

Honest status

At the time of writing, the running container still serves the old behaviour:

$ curl -sI https://hetsulab.tech/notes
HTTP/2 301
location: http://hetsulab.tech/notes/

The fix is committed but not deployed. The served file inside the image has a last-modified of Fri, 20 Nov 2026 18:10:37 GMT; the nginx.conf change landed at 18:12:43. The image was built before the config change, so it is still running the old nginx.conf — that’s the explanation the timestamps support, and it’s the reason the response hasn’t moved. A rebuild (docker compose -f docker-compose.attach.yml up -d --build) is what puts the new config in front of traffic. I’d expect the next check to show location: /notes/; I haven’t observed that yet, so I’m not writing it down as a result.

The general shape of it

If TLS terminates somewhere in front of you, your backend’s idea of the scheme is wrong by design. nginx is the one case where that leaks into a response header users follow: directory redirects, return 301 $scheme://..., anything that rebuilds a URL. Redirect relatively and let the client keep the origin it already has. Then go find the other places you interpolate $scheme, because there are usually one or two.