목차

, , ,

Caddy Config

Caddyfile과 native JSON 구성에서 자주 확인하는 기본 구조, 핵심 directive, 검증 절차를 정리한다.

Summary

Format

example.com {
	root * /srv/www/example
	encode zstd gzip
	file_server
}

Structure

Global Options Block

{
	email [email protected]
	admin 127.0.0.1:2019
}

Site Block

Common Directives

Minimal Templates

Static Site

example.com {
	root * /srv/www/example
	encode zstd gzip
	file_server
}

Reverse Proxy

app.example.com {
	reverse_proxy 127.0.0.1:3000
}

Reverse Proxy with Headers

app.example.com {
	reverse_proxy 127.0.0.1:3000 {
		header_up Host {host}
		header_up X-Forwarded-Proto {scheme}
		header_up X-Forwarded-For {remote_host}
	}
}

Local HTTP Development

:8080 {
	root * ./public
	file_server
}

Required Fields By Scenario

Static Web Server

Reverse Proxy

HTTPS With Public Domain

Local HTTPS

Caddy는 site address와 상황에 따라 자동 HTTPS를 시도한다. 따라서 NGINX처럼 항상 listen 443 ssl 과 인증서 경로를 직접 적는 방식으로 생각하면 동작을 오해하기 쉽다.

File Layout

Common Paths

Caddyfile vs JSON

Validation

caddy fmt --overwrite ./Caddyfile
caddy adapt --config ./Caddyfile --pretty --validate
caddy validate --config ./Caddyfile
caddy reload --config ./Caddyfile

Troubleshooting

See Also

History