Skip to content
Tuntii edited this page Dec 3, 2026 · 2 revisions

Deploy (cleartext behind a reverse proxy)

Viltrum speaks cleartext HTTP/1.1 on TCP by default. For TLS at the edge, put Caddy, nginx, or another reverse proxy in front. viltrum can also serve HTTPS itself (app.listen_tls, see TLS); a proxy is still the better edge when you need HTTP/2, ACME or the fastest bulk TLS.

Recommended shape

client ──HTTPS──▶ reverse proxy ──HTTP──▶ viltrum :8080

Bind Viltrum to loopback or a private interface:

app.listen('127.0.0.1:8080')!

What the proxy must get right

Concern Guidance
Host Forward the original host (Host / X-Forwarded-Host as you prefer). Viltrum requires Host on HTTP/1.1 by default.
Timeouts Proxy idle/read timeouts should be ≥ app idle_timeout / read_timeout (defaults 60s / 30s) or intentionally shorter if you want the proxy to cut first.
Body size Proxy client_max_body_size (or equivalent) should match or sit under max_body_bytes (default 1 MiB) so errors are consistent.
HTTP/2 at edge Fine. Proxy terminates H2 and talks HTTP/1.1 to Viltrum.

Caddy (sketch)

example.com {
	reverse_proxy 127.0.0.1:8080
}

nginx (sketch)

HTTP only:

server {
	listen 443 ssl;
	server_name example.com;

	location / {
		proxy_pass http://127.0.0.1:8080;
		proxy_http_version 1.1;
		proxy_set_header Host $host;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		proxy_set_header X-Forwarded-Proto $scheme;
		proxy_read_timeout 60s;
	}
}

WebSocket path (v0.13 reference only, WebSocket is not in 1.0):

location /ws {
	proxy_pass http://127.0.0.1:8080;
	proxy_http_version 1.1;
	proxy_set_header Host $host;
	proxy_set_header Upgrade $http_upgrade;
	proxy_set_header Connection "upgrade";
	proxy_read_timeout 3600s;
}

Process model

  • One process; several listen addresses with app.serve (cleartext and TLS side by side).
  • Stop: SIGINT/SIGTERM stop accepting, and open connections are closed within a second. Responses not sent by then are lost (deferred ones included), so drain at the load balancer before stopping.
  • Run under your supervisor (systemd with Restart=always, container restart policy, etc.): a panic exits the process.

Trust and headers

Viltrum does not interpret X-Forwarded-* for security decisions. If you build auth or rate limits on client IP, strip or overwrite untrusted hop headers at the proxy and document which hop you trust.

Related

Clone this wiki locally