SONUB home EN English 한국어 日本語 中文 हिन्दी বাংলা اردو Español Português Français Deutsch Русский العربية Bahasa Indonesia Tiếng Việt ไทย Türkçe

How to enable notifications

Notifications are unavailable in this browser or on this address. Try a supported browser on the secure SONUB site.

If notifications are blocked, allow them in your browser settings.

  1. Open the site controls beside the address bar, or your browser’s site settings. Set Notifications for this site to Allow.
  2. In your device settings, allow notifications for your browser and check Do Not Disturb or Focus.
  3. Return to SONUB, reload the page, and use the bell to enable notifications.

On iPhone or iPad, add SONUB to your Home Screen, open it there, then allow notifications.

All Vibe Coding topics
VIBE CODING

Web Server

Twenty lines of that a will talk to.

A web is simply a that waits for a and sends a . To prove it, we build one out of bash, and a — you can read every line of it — and then move to Caddy, the server that runs real sites with included.

Caddy: a real web server that stays readable

Caddy is a modern web server in a single executable file. It is worth learning right after the shell example because it keeps the same feeling — a few readable lines and it is running — while solving everything the shell version cannot.

Its headline feature is automatic HTTPS. Give it a real and it obtains a , installs it, renews it before it expires, and visitors from http to https. On other servers that is a chore you repeat every few months.

Installing it

install
# macOS
brew install caddy

# Ubuntu / Debian
sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https
sudo apt update && sudo apt install caddy

# Docker alone is enough
docker run -p 8080:80 -v "$PWD":/usr/share/caddy caddy

Serving a folder in one command

No configuration file needed. Go to the folder holding your index.html and run one command — this is the fastest way to show a page to someone on the same network.

terminal
# serve this folder's index.html on port 8080
caddy file-server --listen :8080

# add a directory listing for folders without an index.html
caddy file-server --listen :8080 --browse

The Caddyfile

For anything permanent you write a Caddyfile. It is a plain text file, and a whole site can be four lines long.

Caddyfile
example.com {
	root * /var/www/html
	file_server
	encode gzip zstd
}
  1. example.com {The site address. Write a real domain here and Caddy arranges the HTTPS certificate on its own; write localhost and it serves plain http for local work.
  2. root * /var/www/htmlWhere the files live on disk. The star means it applies to every path of this site.
  3. file_serverActually serve those files. Without this line Caddy answers the request with nothing.
  4. encode gzip zstdCompress responses before sending them. One word, and pages arrive noticeably faster on slow connections.
About that certificate

Caddy asks Let's Encrypt for a free certificate, which requires the domain's to point at your machine and ports 80 and 443 to be reachable. If a proxy in front of it answers those ports instead, the check fails and the certificate never arrives — which is the single most common reason a first Caddy setup does not turn green.

Reverse proxy: passing the request on

Most sites are not files on disk; they are an application listening on some local port. A is a server that takes the public request and hands it to that application, then returns its answer. One line does it.

Caddyfile
sonub.com {
	reverse_proxy sonub-web:3000
}

dl.sonub.com {
	root * /srv/files
	file_server browse
}

This is also how one machine hosts many sites. Only one program may hold port 443, so Caddy holds it, reads which domain each visitor asked for, and forwards each one to a different application behind it.

The commands you need

CommandWhat it does
caddy runRun in the foreground and print the log to the terminal. This is what you want while you are still getting the configuration right.
caddy startRun in the background and return your prompt. Fine for a quick demo; a proper server runs it as a system service instead.
caddy reloadLoad the changed configuration without dropping a single connection. Editing a Caddyfile does not require a restart.
caddy fmt --overwriteReformat the file properly in place. Indentation matters more than it looks, and this settles every argument about it.
caddy validateCheck the configuration for mistakes without starting anything. Run it before you reload a live server.
This site runs exactly like that

One Caddy holds ports 80 and 443 on the SONUB server and splits traffic by domain name: the main site goes to the application , the download subdomain is served straight from disk. Adding a new site means adding one file like the one above and reloading — no restart, and no second program fighting for the port.

You mark this yourself. Nothing is graded here.

Mark this step as understood?

This cannot be undone yet, so mark it only when you really understand.

Marked as understood

You mark this yourself. Nothing is graded here.