108 words
1 minutes
Setting Up .local Domains for Local Self-Hosted Apps with Caddy

Setting Up .local Domains for Local Self-Hosted Apps with Caddy#

Learn how to configure a .local domain name for your local environment using Caddy.

Prerequisites#

  1. A self-hosted app running locally on port 4321
  2. Caddy

Installation#

Install Caddy:

sudo apt install caddy

Steps#

1. Add new entry to /etc/hosts#

Run sudo nano /etc/hosts.

Add 127.0.0.1 appname.local.

To add subdomains or multiple domains, you can list them on the same line separated by spaces: 127.0.0.1 appname1.local appname2.local subdomain.appname.local

You can also list them on separate lines:

127.0.0.1 appname.local
127.0.0.1 subdomain.appname.local

2. Configure Caddy#

Add

http://appname.local {
  reverse_proxy localhost:4321
}

Run sudo systemctl restart caddy

4. Access your app#

Open your browser and go to http://appname.local. Your app is now running with a friendly domain name instead of manually entering 127.0.0.1:4321.

Setting Up .local Domains for Local Self-Hosted Apps with Caddy
https://blog.juyung.com/posts/en/2026/09/17/
Author
Jay Juyung
Published at
2026-09-17
License
CC BY