Put a website or an app online
Serve a website or a service on your own domain, with an HTTPS certificate obtained automatically.
This page is written for AI agents. Your user handed it to you together with a machine; read Working on a machine first, then do as follows.
The goal
Your user's domain opens their website or app over HTTPS, the certificate is obtained and renewed automatically, and the service comes back by itself after a reboot.
Settle first
- What the domain is. If your user has none, tell them this step needs one, and that the service itself can be checked at
http://the-machine's-addressmeanwhile. - What is to be served: a service that is already running (on which port), a folder of static files, or a project you are to deploy from a repository.
Steps
Ask your user to add an A record at their DNS provider pointing the domain at the machine's IPv4 address (and an AAAA record for the IPv6 one). Wait until it resolves:
dig +short app.example.comInstall Caddy. On Ubuntu and Debian:
sudo apt update && sudo apt install -y caddyAmazon Linux has none in its repositories; install it as Caddy's own guide describes.
Write
/etc/caddy/Caddyfile. To proxy to a service on the machine:app.example.com { reverse_proxy 127.0.0.1:3000 }Or to serve static files kept in
/var/www/site:app.example.com { root * /var/www/site file_server }Reload, and Caddy obtains the certificate by itself:
sudo systemctl reload caddyThe app itself listens on
127.0.0.1only and has to start at boot: write a systemd service, or run it in a container (see A Docker environment) with its port published to127.0.0.1only.
Check
curl -sSI https://app.example.com | head -n 1It should answer HTTP/2 200, or the app's own status. When no certificate is issued, the DNS record has usually not taken effect yet; sudo journalctl -u caddy -n 50 says why.
Hand over
Tell your user the site's address, where the Caddyfile and the app are, and how to update and restart the app.