![]()
General
Note
Caddy is the first and only web server to use HTTPS automaticallyΒ and by default.
Repository
- Caddy: Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS π (Recommended)
- dist: Resources for packaging and distributing Caddy
Documentations and Articles
- Automatic HTTPS
- Caddy Server and Umami analytics platform
- Caddy Server Documentation
- Common Caddyfile Patterns
Caddy Commands
Use the documentation to get valid command to handling Caddy Server
To reload configuration use reload command. Doc: caddy reload
caddy reload --config /location/caddy/fileTo check and validate configuration from caddyfile use validate command. Doc: caddy validate
caddy validate --config /location/caddy/fileNote
With
Caddy V2, mostlywebsocketautomatically serve and do not need to configuration likev1. Check about that in Caddy Proxy
You can format the caddyfile to standard and quality version by command. Doc: caddy fmt
caddy fmt --overwrite --config /location/caddy/fileCaddy Configuration
Default
# The Caddyfile is an easy way to configure your Caddy web server.
#
# Unless the file starts with a global options block, the first
# uncommented line is always the address of your site.
#
# To use your own domain name (with automatic HTTPS), first make
# sure your domain's A/AAAA DNS records are properly pointed to
# this machine's public IP, then replace ":80" below with your
# domain name.
:80 {
# Set this path to your site's directory.
root * /usr/share/caddy
# Enable the static file server.
file_server
# Another common task is to set up a reverse proxy:
# reverse_proxy localhost:8080
# Or serve a PHP site through php-fpm:
# php_fastcgi localhost:9000
}
# Refer to the Caddy docs for more information:
# https://caddyserver.com/docs/caddyfileBasic Auth
If you want to add a basic-auth for Caddy, you can workaround function integrated inside Caddy. Read more at Caddy - basic_auth
First of all, you need to use CLI of caddy with hash-password to create your credential with your account, because Caddy only apply the hash-password for authenticate, so thatβs why you need it
caddy hash-password <your-username>Prompting your password and you will receive the hash in the end, copy that and ready to put into Caddyfile
https://your-domain.needto.ssl {
basic_auth {
<user-name> <hash-password> # e.g: nash $2a$14$Zkx19XLiW
}
...
<your configure>
}More interesting example at Single Sign-on in Caddy Server Using only the Caddyfile and Basic Authentication