Skip to content

Proxy & HTTPS

lokl includes a built-in reverse proxy that provides automatic HTTPS for your services.

proxy:
domain: myproject.dev
services:
frontend:
command: pnpm dev
port: 5173
subdomain: app

This makes the frontend available at https://app.myproject.dev.

  1. Certificate Generation — lokl generates self-signed certificates for your domain
  2. Trust Store — Certificates are added to your system trust store
  3. DNS — Entries added to /etc/hosts for local resolution
  4. Routing — Requests are proxied to the appropriate service based on subdomain

Assign subdomains to services:

services:
frontend:
port: 5173
subdomain: app # → https://app.myproject.dev
api:
port: 3000
subdomain: api # → https://api.myproject.dev
admin:
port: 4000
subdomain: admin # → https://admin.myproject.dev

A service without a subdomain gets the root domain:

services:
main:
port: 3000
# No subdomain → https://myproject.dev

For SPA routing or API prefixes:

services:
api:
port: 3000
subdomain: api
rewrite:
strip_prefix: /v1
fallback: /index.html

Setup DNS entries:

Terminal window
sudo lokl dns setup

Remove DNS entries:

Terminal window
sudo lokl dns remove

In the TUI, press p to toggle between:

  • Local — Direct connection to service
  • Remote — Through HTTPS proxy