Ops and security

Before you redirect to https, check who still speaks http

30 November 2026 · 2 min read · For engineers
AI draft · edited and approved by Steen Kramer Jensen

"Redirect all http to https and turn on HSTS" is standard advice, and for a website it is right. A review of my own server said exactly that about one of my sites: port 80 answered without encryption and without a redirect.

The problem is that the same host serves two things. One is the company website, read by browsers. The other is an API used by devices in the field for a backup power supply project, and they talk to it over plain http.

Browsers follow redirects, devices may not

A browser that gets a 301 simply goes to the new address. A small embedded client is a different animal:

  • It may not follow redirects at all.
  • It may not be able to do TLS, or not with today's certificates.
  • Many clients turn a redirected POST into a GET, so the data is dropped on the way.
  • It cannot be updated in an afternoon. Devices in the field are updated when they can be reached.

A blanket redirect would look like a clean security fix on the server and like a dead backend from the device's side.

Look in the access log first

Before you add the redirect, ask the log who still arrives on port 80 and what they ask for. With Apache's vhost_combined log format the first field is host and port, so this counts the paths requested over plain http:

awk '$1 ~ /:80$/ {print $8}' access.log | cut -d'?' -f1 | sort | uniq -c | sort -rn

Look at the user agents on the busy paths too. Anything that is not a browser or a crawler deserves a closer look before you change what it gets back.

Redirect everything except what devices use

On my server the answer became a redirect with a named exception:

RewriteCond %{REQUEST_URI} !^/api(/|$)
RewriteCond %{REQUEST_URI} !^/\.well-known/
RewriteRule ^ https://www.sysapp.dk%{REQUEST_URI} [R=301,L]

The website goes to https. The API path stays reachable over http, with a comment in the config saying why. The HSTS header is set on the website only, for the same reason.

An exception is a debt, not a fix

This does not make the device traffic safe. It still travels unencrypted, and that stays on my list as an open item until the devices can speak https. What the exception buys is that the website is fixed today without breaking hardware I cannot reach today.

Write the exception down where the next person will see it, and say what has to happen before it can go.

Check who is on the other end before you change what the server says to them.

How this note was madeThe first draft of this note was written by AI (Claude) from Steen's own notes and project material. Steen Kramer Jensen edited and approved it before it was published.