For the complete documentation index, see llms.txt. This page is also available as Markdown.

38.3 Caddy Web Server

Caddy is an open-source web server written in Go that provides secure web services.

Installing Caddy

Install using the pkg package manager:

# pkg install caddy

Or install using Ports:

# cd /usr/ports/www/caddy/
# make install clean

After installation, you can view the Caddy package documentation to understand the necessary configuration and precautions:

# pkg info -D caddy

Configuring Caddy

Directory structure:

/
├── usr
   └── local
       ├── etc
          ├── caddy
             └── Caddyfile              # Caddy main configuration file
          └── rc.d
              └── caddy                  # Caddy RC service script
       └── www
           └── caddy
               └── index.html             # Caddy test page
└── var
    ├── log
       └── caddy
           └── caddy.log                  # Caddy runtime log
    ├── db
       └── caddy
           ├── data
              └── caddy                  # Automatic SSL certificate storage
           └── config
               └── caddy                  # Configuration auto-save
    └── run
        └── caddy
            └── caddy.sock                 # Management endpoint Unix socket

Note

Since non-privileged users cannot bind to port 443, the error listen tcp :443: bind: permission denied will occur.

Install the security/portacl-rc mentioned above by executing the following commands:

Configure the service by executing the following commands in order:

Create a test page by executing the following command to create the directory:

Edit the /usr/local/www/caddy/index.html file and write the test content:

Start the Caddy service:

Open https://localhost/ locally to view the test page:

Caddy FreeBSD

References

  • OVVV. Caddy Installation and Usage Tutorial[EB/OL]. [2026-03-25]. https://blog.ovvv.top/posts/f3ac7ef6/. The HTML for the test page in this section is from this source.

Last updated