Caddy
Web ãµãŒã CaddyïŒãã£ãã£ïŒã«ã€ããŠãŸãšããŠããŸãã
2020幎5æãCaddy 2.0.0 ãæ£åŒå
¬éãããŸããã
2022幎9æã«ã¯ Caddy 2.6.0 ãå
¬éãããŠããŸãã
éçºã¯ãã§ã« Caddy v2 ã§æŽæ°ãããv1 ã¯ã»ãã¥ãªãã£çãªä¿®æ£ã«çããããŸãã
ãã®ãããåºæ¬çã«ã¯ Caddy v2 ã§ã®äœ¿çšãããããã§ãã
Caddy v2 ãš Caddy v1 ã§ç°ãªããšãããããã€ãååšããŸãã
å
¬åŒ Web ãµã€ã㯠Caddy v2 åãã«çœ®ãæããããŠããŠã
Caddy v1 ã¯ããã¥ã¢ã«ã®ã¢ãŒã«ã€ããªã©ãäžéšæ
å ±ãæ®ãããŠããŸãã
Caddy é¢é£ã§æ€çŽ¢ããå Žåãªã©ã
Caddy v2ã»Caddy v1 ã©ã¡ãã®èšèŒã泚æããŠåç
§ããŠäžããã
ç®æ¬¡
Caddy 2.7 ã®æ³šæ
ããŒãžéå¶è
ãåšèŸºã®å©çšè
ã«ããå ±åããŸãå
¬åŒ  GitHub Issues ã  ãã©ãŒã©ã ãã
Caddy 2.7 ç³»ãéå»ã®äžã§æãäžå®å®ãªããŒãžã§ã³ã«ãªã£ãŠããäºã確èªããŠããŸãã
Caddy 2.7.0ïœ2.7.1 ã¯ããã«ããŠã³ããŠãŸãšãã«åäœããã
Caddy 2.7.2 以éãå©çšæ¹æ³ã«ãã£ãŠã¯åé¡ãçºçããäºã確èªã§ããŠããŸãã
å
¬åŒã§ãåé¡èŠãããŠããŠãCaddy 2.8 ã¯æ°æ©èœãè¿œå ãããå®å®åããäºã決å®ããŠããŸãã
Caddy 2.7 ç³»ãžæŽæ°åŸ Web ã§äœã ãã®åé¡ãçºçããŠããå Žåã¯ã
Caddy 2.6.4 ãŸã§æ»ãããOS ããã±ãŒãžçã® Caddy ãžåãæ¿ããŠã¿ãŠäžããã
 Caddy is on a feature freeze until after the 2.8 release #5704 | GitHub caddyserver/caddy ussues
 Releases | GitHub caddyserver/caddy - v2.7 ç³»ã¯ããã€ã䜿ããªãããã«èšèŒ
å ¬åŒã»é¢é£ãµã€ã
- Â Caddy
- Download - ã¢ãžã¥ãŒã«ä»ãã€ããªãŒ
- Documentation
- Â GitHub
- Issues - äžå ·åå ±å
-  Forum (Community) - ãµããŒãæ²ç€ºæ¿
- Wiki - ãã³ãïŒãã°ã€ã³ããŠããã°èª°ã§ãç·šéå¯ïŒ
ç¹åŸŽ
Caddy ã¯æ¬¡ã®ç¹åŸŽããããŸãã
- ç¡æçºè¡ã§ãã SSL 蚌ææž Let’s Encrypt ãèªåçºè¡ã»æŽæ°ãã
容æã« SSL ãå®çŸããŸãã å©çšè ã¯æèããã« SSL åãå®çŸããŸãã
æåçºè¡ããã SSL 蚌ææžãé©çšããäºãã§ããŸãã - Caddy 2.6 ãã HTTP/3 ã«æšæºå¯Ÿå¿ããŠããŸãã
TLS 1.3 ã«ã察å¿ãé«é衚瀺ãå®çŸããŠããŸãã
èšå®ã«ãã Zstandard gzip å§çž®ãå¯èœã§ãã - HTML ãªã©ã« Go èšèªã®ãã³ãã¬ãŒããé©çšã§ããŸãã
ïŒApache ã® SSI ã¿ãããªäºãã§ããŸãïŒ - php-fpmïŒWindows 㯠php-cgiïŒãçšã㊠PHP ã®åäœãå¯èœã§ãã
- ãªããŒã¹ãããã·ã«å¯Ÿå¿ããŠããŸãã
- Caddyfile ã¯ãšãŠãã·ã³ãã«ã«èšèŒã§ããç®çã®èšå®ã容æã«å®çŸã§ããŸãã
json ã«ãã詳现ãªèšå®ãå¯èœã§ãã - API ãååšããèšå®ãªã©ãä»ãã調æŽã§ããŸãã
- ã¢ãžã¥ãŒã«ãååšããæ©èœæ¡åŒµãå¯èœã§ãã
ããã§ã¯ãåäœãããããã®å¿ èŠæäœéã®æ å ±ãèšèŒããŠããŸãã
ã€ã³ã¹ããŒã«
ããã§ã¯ãã€ããªãŒã§ã®ã€ã³ã¹ããŒã«æ¹æ³ãèšèŒããŠããŸããã
ãœãŒã¹ãé
åžãããŠããŠããã«ãããäºãå¯èœã§ãã
Caddy v2
ãã€ããªãŒïŒå®è¡ãã¡ã€ã«ïŒãé åžãããŠããŸãã®ã§ãããŠã³ããŒãããŸãã
Windows ã§ã¯ã·ã§ãŒãã«ãããäœæãããšäŸ¿å©ã§ãã
ïŒCaddy v2 ã§ã¯ caddy run ãªã©ãå¿
ããªãã·ã§ã³ãå¿
èŠã«ãªããŸãïŒ
ä»ã® OS ã§ã¯ /usr/bin
ã /usr/loal/bin
ãž caddy ãå
¥ããŸãã
 Install | Caddy Documentation
å ¬åŒæé ã©ããã«è¡ã£ãŠããŸãåäœããªãå Žåãã«ãŒãã«å¶åŸ¡æ©èœã確èªããŠäžããã
Caddy v1
Caddy v1 ç³»ã®ææ° 1.0.4 ã¯æ¬¡ããããŠã³ããŒãã§ããŸãã
ãœãŒã¹ã¬ãã«ã§ã¯ 1.0.5 ãå
¬éãããŠããŸãã
 caddyserver/caddy tag v1.0.4 | GitHub
å ¬åŒãµã€ãã§ã¯ããŠã³ããŒãã§ããªããªã£ãŠããŸãã
Scoop
ð Scoop 㯠Caddy ã«å¯Ÿå¿ããŠããŸãã
次ã®ã³ãã³ãã§å®¹æã«ã€ã³ã¹ããŒã«å¯èœã§ãã
scoop install caddy
éåžžææ°å®å®çãã€ã³ã¹ããŒã«ããŸããããŒãžã§ã³æå®ãå¯èœã§ãã
webinstall.devã»webi
 Caddy | webinstall.dev
ð webinstall.devã»webi | ãµãããð FU-SEN
Windows ã§ææ°çãããŠã³ããŒãã»ã€ã³ã¹ããŒã«:
curl.exe https://webi.ms/caddy | powershell
ä»ã® OS ã§ææ°çãããŠã³ããŒãã»ã€ã³ã¹ããŒã«:
curl -sS https://webi.sh/caddy | sh
Webi ã§ææ°å®å®çãããŠã³ããŒãã»ã€ã³ã¹ããŒã«:
webi caddy
Webi ã§ã¯ webi caddy@beta
ã§ããŒã¿çãç°¡åã«ã€ã³ã¹ããŒã«ã§ããŸãã
ãŸã Caddy v1 㯠webi caddy@1.0.4
㧠1.0.4 ãã€ã³ã¹ããŒã«å¯èœã§ãã
Caddy v1.0.5 ã¯ãã€ããªãŒå
¬éãããŠããªãã®ã§ãã€ã³ã¹ããŒã«ã§ããŸããã
Caddy å ¬åŒãµã€ã
å
¬åŒãµã€ãã§ã¯ã¢ãžã¥ãŒã«ãå梱ãããã€ããªãŒãããŠã³ããŒãã§ããŸãã
以å Caddy v1 ã§è¡ãããŠããé
åžæ¹æ³ã§ããã
Caddy v2 ã®ã¢ãžã¥ãŒã«ãæŽããããŠã³ããŒãããŒãžãæ¹ããŠèšçœ®ãããŠããŸãã
xcaddy
xcaddy ã䜿çšãããšããã©ã°ã€ã³ãå«ã Caddy ããã«ãã§ããŸãã
 Release | Caddy caddyserver/xcaddy
Release ãã xcaddy ãããŠã³ããŒãã§ããŸãã
å
¬åŒ Docker ã䜿çšããå Žåãcaddy:builder
ã« xcaddy
ãå«ãŸããŠããŸãã
ãã«ããã Caddy 㯠/usr/bin/caddy
ã«ãããŸãã
äŸãã°ãã®ãã㪠Dockerfile
ãäœæããŸãã
FROM caddy:<version>-builder AS builder
RUN xcaddy build --with github.com/caddy-dns/cloudflare
FROM caddy:<version>
COPY --from=builder /usr/bin/caddy /usr/bin/caddy
æŽæ°
Caddy v2.4 ããããã§ã« Caddy ãã€ã³ã¹ããŒã«ããŠããå Žåã¯
次ã®ã³ãã³ã㧠Caddy ãæŽæ°ã§ããããã«ãªããŸããã
caddy upgrade
çŸåšã® caddy
ãã€ããªãŒã眮ãæããŸãã
ã¢ãžã¥ãŒã«ãé©çšããŠããå Žåã¯é©çšãããã€ããªãŒã«ãªãããã
ç¹ã«å
¬åŒãµã€ãã§ããŠã³ããŒãããã¢ãžã¥ãŒã«å梱ãã€ããªãŒã®å Žåã¯
ãã®æ¹æ³ã§æŽæ°ãããšè¯ãã§ãããã
Caddyfile
Caddyfile 㯠Caddy v1 ãš Caddy v2 ã§èšèŒãç°ãªããŸãã
Caddy v2
åºæ¬çã« /etc/caddy/Caddyfile
ãžé
眮ãããŸããã
æè¿ã¯ãã®å Žæãå€ããŠã Caddy ã®ããã±ãŒãžæŽæ°ã§
ããã©ã«ãã«æ»ãå ŽåããããŸãã
ïŒããã«ãã systemd 㧠Caddyfile ã®åç
§ãå€ããŠãããš
ãããã±ãŒãžæŽæ°åŸåç
§ã§ããªããªããŸãïŒ
ãã®ãã /etc/caddy/Caddyfile
ãç·šéããŠç¶æããã®ãããããã§ãã
ä»ã®å Žæã«ãããã¡ã€ã«ãèªã¿èŸŒã¿ããå Žåã¯/etc/caddy/Caddyfile
㧠import
ãæå®ããŠäžããã
import èªã¿èŸŒããã¡ã€ã«å
Caddy ã§åäœãããµãŒãã 1 ãã¡ã€ã³ã®ã¿ã§ããã°ã次ã®ãããªèšå®ã§ãã
example.net.eu.org
tls mail@ddress.example.net
root * D:\Caddy\example.net.eu.org
encode zstd gzip
file_server
ãµããã¡ã€ã³ãä»ã®ãã¡ã€ã³ãèšå®ãããå Žåã¯ããã¡ã€ã³åæ¯ã« {
}
ã§å²ã£ãŠäžããã
example.net.eu.org {
tls mail@ddress.example.net
root * D:\Caddy\example.net.eu.org
templates
encode zstd gzip
file_server
}
www.example.net.eu.org {
tls mail@ddress.example.net
redir https://example.net.eu.org{uri}
}
blog.example.net.eu.org {
tls mail@ddress.example.net
root * D:\Caddy\example.net.eu.org
php_fastcgi 127.0.0.1:9000
encode zstd gzip
file_server
}
social.example.net.eu.org {
tls mail@ddress.example.net
reverse_proxy localhost:3000
}
- encode - å§çž®ãä»å ããŸãã
zstd
gzip
ãèšå®ã§ããŸãã - file_server - ãã¡ã€ã«ãµãŒããæå¹ããŸããéåžžãããå ¥ããŸãã
- php_fastcgi - php-fpm ãŸã㯠php-cgi ã®åŸ
æ©å
ãèšèŒããŸãã
ããŒãã®ä»£ããã«unix//run/php-fpm/www.sock
ã®æå®ãå¯èœã§ãã
ãããæå¹ã«ããå Žåããã¡ã€ã«ãååšããªãå Žå㯠index.php ãåç §ããŸãã
ïŒ2.0.0b19 㯠PHP ãåäœããªãäžå ·åããããŸãïŒ - root -
*
ã«åŒãç¶ãåç §å ã®ãã£ã¬ã¯ããªãå ¥ããŸãã - tls - SSL ãµãŒã蚌ææžçºè¡ç³è«ããã¡ãŒã«ã¢ãã¬ã¹ïŒæšå¥šïŒ
tls 蚌ææž ããŒ
ãšèšèŒããæåã®èšŒææžã䜿çšããäºãã§ããŸãã
ããŒãçªå·ãæå®ãtls
ãå ¥ããŠããªãå Žå㯠HTTP éä¿¡ããããšããŸãã
ïŒCaddy v1 ã®ããã«tls off
ãšæ瀺ããã®ã§ã¯ãªããtls
ããªãããŸãïŒ - templates -  ãã³ãã¬ãŒã ãæå¹ã«ããŸãã
- redir - æå® URL ãžè»¢éããŸããæ«å°Ÿ
{uri}
ã§ãã¡ã€ã³äžãç¶æ¿ã§ããŸãã - reverse_proxy - æå®ã®
ãµãŒããŒ:ããŒã
ãžã®ãªããŒã¹ãããã·ãå®çŸããŸãã
ç¹ã« Caddy v2 ã§ã¯ WebSocket ãèæ ®ããããã® 1 è¡ã§åäœã§ããäºãå€ãã®ã§ã
Nginx ã®èšå®ãç¥ã£ãŠãã人ã¯é©ããããããŸããã
åå€ã§ã¯ *
ã /dir/*
ãä»å ããŠãç¹å®ãã£ã¬ã¯ããªäžã§ã®åäœãå¯èœã§ãã
äŸãã°æ¬¡ã®å Žå㯠/blog/ äžã§ PHP ãåäœãããŸãã
php_fastcgi /blog/* localhost:9000
tls
ã«èšèŒããã¡ãŒã«ã¢ãã¬ã¹ïŒèšŒææžçºè¡ã§äœ¿çšããã¡ãŒã«ã¢ãã¬ã¹ïŒãCaddyfile
å
ã®ãã¡ã€ã³ã§ãã¹ãŠåãå Žåããã¡ã€ã³æ¯ tld
ã䜿ã代ããã«
次ã®èšèŒã Caddyfile
ã®å
é ã«å
¥ããäºãã§ããŸãã
{
email mail@ddress.example.net
}
ãã詳现ã¯èª¬æã¯æ¬¡ãåç §ããŠäžããã
Caddy v1
Caddy v1 ã§ã¯ã次ã®ãã㪠Caddyfile ã«ãªããŸãã
example.net.eu.org
tls mail@ddress.example.net
root D:\Caddy\example.net.eu.org
gzip
example.net.eu.org {
tls mail@ddress.example.net
gzip
markdown / {
css /css/blog.css
js /css/scripts.js
}
errors {
403 403.html
404 404.html
500 500.html
502 502.html
503 503.html
}
}
www.example.net.eu.org {
tls mail@ddress.example.net
redir https://example.net.eu.org{uri}
}
blog.example.net.eu.org {
tls mail@ddress.example.net
gzip
fastcgi / 127.0.0.1:9000 php
on startup php-fpm7
}
social.example.net.eu.org {
tls mail@ddress.example.net
proxy / http://127.0.0.1:3000
}
ãã¡ãã«æ§ã ãªå©çšæ¹æ³ã®ãµã³ãã«ããããŸãã
 caddyserver/examples | GitHub (Caddy v1)
Q&A
Caddy ã¯ã©ã®äœã®åŠçèœåããããŸããïŒ
 Can I use Caddy for a high-traffic site? | Caddy Forum
Caddy 1 ã§ã¯ nginx ãšæ¯èŒããŠã®ãã³ããã¹ããè¡ãããŠããŸãã
Caddy 2 ã¯ã€ãããªããããŠããã®ã§ãçµæãç°ãªããšæã£ãŠäžããã
Caddy ãèµ·åã§ããŸããã
èµ·åã§ããªãå Žåãäž»ãªåå 㯠Caddyfile ã®èšèŒãã¹ã§ãã
Windows ã§ã¯ Caddy v2 ã®å®è¡ãã¡ã€ã«ãã¯ãªãã¯ããŠèµ·åã§ããŸããã
PowerShellã»ã³ãã³ã ããã³ããã»Git Bash ãªã©ãèµ·åããcaddy run
ã§èµ·åãããŠäžãããïŒPowerShell 㯠./caddy run
ïŒ
éåžžéçšæã¯ã·ã§ãŒãã«ãããäœããšäŸ¿å©ã§ãã
ã·ã§ãŒãã«ãããã¹ã¿ãŒãã¢ããã«å
¥ããŠèªåèµ·åãã§ããŸãã
Caddyfile 㯠Caddy v1 ãš Caddy v2 ã§èšèŒãç°ãªããŸãã
åèã«ããããŒãžã Caddy v1 åãã Caddy v2 åãã確èªããŠäžããã
èªåèµ·åã倱æããå Žåãèµ·åãã¡ã€ã«ããã確èªããŠã¿ãŠäžããã
Caddy ãèµ·åããŸããããã©ãŠã¶ããåç §ã§ããŸããã
äŸãã° Google Chrome ã§åç
§ããæ ERR_SSL_PROTOCOL_ERROR
ãåºãŠããå Žåã
䞻㫠Let’s Encrypt ããã®èšŒææžçºè¡ã«å€±æããŠããŸãã
äŸãã°ããŒã ãµãŒããåãæ¿ããŠããªãããåãæ¿ããã°ããã§ã
Let’s Encrypt ã®çºè¡ãµãŒããã Caddy ãåç
§ã§ããªãæã§ãã
ãã®å ŽåãããŒã ãµãŒãã®èšå®ãå€æŽããŠæ°æéåŸã«å床起åããŠã¿ãŠäžããã
ãã®ä»ãCaddy èµ·åçŽåŸã« Let’s Encrypt ãšãããšããããŠããããã
èµ·åããæ°ç§çµéããŠãã°ãåç
§ãããšãåå ãææ¡ã§ããŸãã
Let’s Encrypt ã¯ã¬ãŒãå¶éããããŸãã
ãã°ã«ã¬ãŒãå¶éã®è¡šç€ºãåºãŠããå Žåã¯ã次ãè©ŠããŠã¿ãŠäžããã
- å¥çŽãããŠã® VPS ãªã©ã§çºçããå Žåã
Caddy ãåæ¢ããtls ã¡ãŒã«ã¢ãã¬ã¹
ãä»å ããŠããèµ·åããŠã¿ãŠäžããã - ããŒã ãµãŒããå€æŽãããŠã§åç
§ã§ããªãã£ããšæãããå Žåã¯ã
Caddy ãåæ¢ããæ°æéçµéããŠããèµ·åããŠã¿ãŠäžããã - äœåºŠã倱æããŠè©Šè¡ããŠããå Žåããã¡ã€ã³ç®¡çæ°ãå€ãäžæ°ã«çºè¡ããå Žåã¯
24 æéïœ1 é±éåŸ ã€å¿ èŠãããå ŽåããããŸãã
Let’s Encrypt ã®ããŒãžã§ãã¬ãŒãå¶éã«ã€ããŠè§ŠããŠããŸãã
ð Let’s Encrypt | ãµãããð FU-SEN
Caddy 2.30 ãããLet’s Encrypt ã®çºè¡ã«å€±æããå Žåã
ZeroSSL ã§ã®çºè¡ãè©Šã¿ãããã«ãªããŸããã
crt.sh ã¯èšŒææžã®çºè¡ã確èªããã®ã«äŸ¿å©ã§ãã
åç
§ãã®ãã®ãã§ããªãå Žåã¯ã
ãã¡ã€ã€ãŠã©ãŒã«ã§ããŒããèš±å¯ããŠããªãå ŽåããããŸãã
é垞㯠80ïŒHTTPïŒã»443ïŒHTTPSïŒã§ãã
èªå®
ãªã©ã®ãµãŒãã§ã¯ãã«ãŒã¿ã®è»¢éèšå®ãæ£ãããã確èªããŠäžããã
502 Bad Gateway ãåºãŠããå ŽåãCaddy ã¯æå®ããŠããä»ãµãŒãã¹ãåç
§ã§ããŸããã
PHP ããªããŒã¹ãããã·ãèšå®ããæã«çºçããå ŽåããããŸãã
䞻㫠localhost:9000
ãªã©ã®èšèŒèª€ãã§ããã
ã«ãŒãã«å¶åŸ¡æ©èœããã¡ã€ã€ãŠã©ãŒã«ãåå ã®å ŽåããããŸãã
Caddy v2 㧠http ã䜿çšã§ããŸããïŒ
å¯èœã§ããããŒãçªå·ãä»ã㊠tls
ããªãå Žåãhttp ã§éä¿¡ããããšããŸãã
éåžž http ã®ããŒãçªå·ã¯ 80 ãªã®ã§ããã¡ã€ã³åã« :80
ãä»ãã tls
ãå€ããŠäžããã
example.net.eu.org:80 {
root * D:\Caddy\example.net.eu.org
templates
encode zstd gzip
file_server
}
Cloudflare CDN ãçµç±ã§ããããã«èšå®ã§ããŸããïŒ
ð Cloudflare | ãµãããð FU-SEN
Let’s Encrypt ãé©çšãã Web ãµãŒãã¹ã§ã¯åé¡ããããŸãã
ãŸã telnetã»ssh ãµãŒããªã©ãä»ã®ãµãŒããåç
§ããå Žåã¯
åç
§å
ã Cloudflare ãµãŒãã«å€æŽãããŠããŸãããããã®æ¹æ³ã䜿çšããªãã§äžããã
çŽæ¥ SSL ãµãŒã蚌ææžãé©çšã§ããããœã³ã³ã VPSã»å°çšãµãŒã ãçšããå Žåã¯
Cloudflare ãçºè¡ãããªãªãžã³èšŒææžïŒOrigin CertificatesïŒãçºè¡ããŠ
SSLïŒTLSïŒéä¿¡ã§å®çŸããäºãå¯èœã§ãã
 Cloudflare ãã䜿çšãã ãã¡ã€ã³ ãéžæããŸãã
DNS ãéžæããŠã ããªã¬ã³ãžã«ãããšå
±ã«ã
ã¿ã€ãïŒCNAME ã³ã³ãã³ãïŒåç
§å
ãµãŒãå ãŸãã¯
ã¿ã€ãïŒA ã³ã³ãã³ãïŒåç
§å
IP ã¢ãã¬ã¹ ãå
¥ããŠãããŸãã
SSL/TLS ãéžæããã客æ§ã® SSL/TLS æå·åã¢ãŒã ã ãã« (å³å¯) ã«ããŸãã
ãªãªãžã³ãµãŒã ãéžæããããªãªãžã³èšŒææžã㮠蚌ææžãäœæ ãã蚌ææžãçºè¡ããŸãã
Windows ã§ã¯ã¡ã¢åž³ãªã©ã®ããã¹ããšãã£ã¿ãèµ·åããŠããã
衚瀺ããã蚌ææžãªã©ããšãã£ã¿ãžè²Œãä»ããŠãã¡ã€ã«ä¿åããŸãã
蚌ææžéšå㯠ãã¡ã€ã³å.pem
ãããŒéšå㯠ãã¡ã€ã³å.key
ãšããŸãã
 Managing Cloudflare Origin CA certificates | Cloudflare
ã(Optional) Step 4 - Add Cloudflare Origin CA root certificatesãã«ãã
cloudflare_origin_ecc.pem ãã¯ãªãã¯ããããŠã³ããŒãã»ãã¡ã€ã«ä¿åããŸãã
ããã§ã¯ãã¡ã€ã³åã example.net.eu.org
ã
ä¿åãã蚌ææžé¢é£ãã¡ã€ã«ã D:\Caddy
å
ã«å
¥ãããšããŠãCaddyfile
ã¯æ¬¡ãšãªããŸãã
example.net.eu.org {
tls D:\Caddy\example.net.eu.org.pem D:\Caddy\example.net.eu.org.key {
ca_root D:\Caddy\origin_ca_rsa_root.pem
}
root * D:\Caddy\example.net.eu.org
templates
encode zstd gzip
file_server
}
ç»åãã¡ã€ã«ãªã©ã¯ãã£ãã·ã¥ä¿ååŸãå床åç
§ãã Status 㯠HIT ãšãªãã
å®å
šã«ãã£ãã·ã¥ãåªå
çã«åºåããããã«ãªããŸãã
Cloudflare CDN ã¯ããã©ã«ã㧠.html ãã¡ã€ã«ããã£ãã·ã¥ã«å
¥ããŸããã
å¿
èŠãªå Žåã¯èšå®ãè¡ãå¿
èŠããããŸãã
Google Cloud Run ã§äœ¿çšã§ããŸããïŒ
ããŒãžéå¶è
ã Google Cloud Run ã§ã®åäœã確èªã§ããŠããŸãã
Google Cloud Run ãçšããäºã§ãµãŒãã®ã»ããã¢ãããäžèŠã§ãçŽ æ©ã䜿çšã§ããŸãã
ð Caddy ã Google Cloud Run ã§åäœãããã| ãµãããð FU-SEN
Docker ã䜿çšããä»ã® Web ãµãŒãã¹ã§ã䜿çšã§ããŸããïŒ
Caddy v2 ã®å
¬åŒ Docker ã€ã¡ãŒãžã䜿çšããŠãããµã³ãã«ã¯
è±èªç Wiki 㧠Dockerfile
ãå
¬éããŠããŸãã
ð Dockerfile for Web services | ð BALLOON | FU-SEN
æ¥æ¬èªãã¡ã€ã³ã䜿çšã§ããŸããïŒ
䜿çšã§ããäºããµã€ãéå¶è
ã確èªã§ããŠããŸãã
Caddyfile ã«ã¯ PunycodeïŒxn--
ã§ã¯ããŸãè±æ°ïŒã§ãã¡ã€ã³åãå
¥ããŠäžããã
 Can’t use Caddy on punycode IDN domains #3017 | GitHub caddyserver/caddy
Let’s Encrypt 以å€ã® SSL 蚌ææžã䜿çšã§ããŸããïŒ
ACME ã«å¯Ÿå¿ããŠãã SSL 蚌ææžã¯ãšã³ããã€ã³ããæå®ããŠèšŒææžãçºè¡ã§ããŸãã
ããã«ãã Let’s Encrypt ã¬ãŒãå¶éã«ãã蚌ææžçºè¡ã«åé¡ãçããŠããå Žåã§ã
ä»ã®èšŒææžãçºè¡ããŠäœ¿çšããäºãã§ããŸãã
 Using ZeroSSL’s ACME endpoint | Caddy Forum
 ZeroSSL
ð ZeroSSL | ãµãããð FU-SEN
Caddyfile
ã®é ã§ãã®ããã«ãããšã
ãã® Caddy å
tls
ãæå®ããªããã¡ã€ã³ã§ã¯ ZeroSSL 蚌ææžãçºè¡ããŸãã
{
acme_ca https://acme.zerossl.com/v2/DV90
email mailaddress@example.com
}
ç¹å®ã®ãã¡ã€ã³ã ãã« ZeroSSL ã䜿çšãããå Žåã¯æ¬¡ã®ããã«èšå®ããŸãã
example.com {
tls mailaddress@example.com {
ca https://acme.zerossl.com/v2/DV90
}
}
 Configure key type to use when creating ACME account (for using Buypass) | Caddy Forum
 Our TLS / SSL certificates | Buypass
 Buypass GO SSL - Endpoints - Updated 14.05.2020 | Buypass Community
ãã®ããã«å€æŽãããš Buypass 蚌ææžãçºè¡ããŸãã
{
acme_ca https://api.buypass.com/acme/directory
email mailaddress@example.com
}
ç¹å®ã®ãã¡ã€ã³ã ãã« Buybass 蚌ææžã䜿çšãããå Žåã¯æ¬¡ã®ããã«èšå®ããŸãã
example.com {
tls mailaddress@example.com {
ca https://api.buypass.com/acme/directory
}
}
ä»ã«ã ACME ã«å¯Ÿå¿ãã蚌ææžã¯å¢ããŠããŠããŸããã
ã¡ãŒã«ã¢ãã¬ã¹ã®ä»£ããã« EAB ãæ¡çšãããªã©ãæ¡ä»¶ãç°ãªãå ŽåããããŸãã
 SSL Configuration in Caddy | Caddy Forum
æåã§çºè¡ãã SSL 蚌ææžã䜿çšã§ããŸãã
ãã¡ã€ã³å
ã® tls
ãçšããŠèšŒææžãšããŒãæå®ããŠäžãããtls
ãæå®ããªããã¡ã€ã³ã§ã¯ ACME ã§çºè¡ãããç¡æã®èšŒææžãé©çšããŸãã
example.com {
tls /etc/ssl/example.com.crt /etc/ssl/example.com.key
:
}
æªè³ªå¯Ÿçã®ããã« IP ã¢ãã¬ã¹ãèæ ®ããå¿ èŠã¯ãããŸããïŒ
Caddy ã§ã¯éåžž IP ã¢ãã¬ã¹ãèæ
®ããå¿
èŠã¯ãããŸããã
æå®ããŠããªããã¹ãåã®åç
§ããã£ãå ŽåãCaddy ã¯ç©ºçœããŒãžãè¿ããŸãã
ãŸã httpâhttps ãçºçããŸãããéåžž IP ã¢ãã¬ã¹ã§èšŒææžãçºè¡ããªãã®ã§ã
TLS handshake error ãšãªããåç
§ã§ããŸããã
å€ãããŒãžã§ã³ã§ã¯ãã°ã«ãã®è¡šç€ºã¯æ®ããŸãããç¹ã«æ°ã«ããå¿
èŠã¯ãããŸããã
æè¿ã®ããŒãžã§ã³ã§ã¯ãã®ãããªãã°è¡šç€ºãè¡ãããŸããã
ãã©ãŒã©ã ã§ã¯æŽã«çªã£èŸŒãã 察çã玹ä»ãããŠããŸãã
 Remote IP behavior analysis and ban | Caddy Forum
404 Not Found ãäœæã§ããŸããïŒ
Caddy 2.1 ãã handle_errors
ã§èšå®ã§ããŸãã
éçãã¡ã€ã«ã§ããã°ãéåžž Not Found ã®ã¿ãæåŸ
ã§ããã®ã§ã404.html
ã衚瀺ããåæã§ã次ã®èšèŒã«ã§ããŸãã
handle_errors {
rewrite * /404.html
file_server
}
HTTP ã¹ããŒã¿ã¹ã³ãŒãã§åŠçãåãããå Žåã¯æ¬¡ã®èšèŒãæå¹ã§ãã
ããã«ãã 404.html
ã 403.html
ãªã©ã䜿çšã§ããŸãã
handle_errors {
rewrite * /{http.error.status_code}.html
file_server
}
ãã³ãã¬ãŒãã§åŠçããäºãå¯èœã§ãã
handle_errors {
rewrite * /error.html
templates
file_server
}
ãŸã php_fastcgi
ã䜿çšããå Žåã.php
ãã¡ã€ã«ããªãåç
§ã¯ index.php
ãåç
§ããã®ã§ãindex.php
㧠404 ã®åŠçãè¡ãããšãã§ããŸãã
ãã®å Žå㯠Caddy 2.0 ã§ã䜿çšå¯èœã§ãã
Caddy v1 㯠errors
ãçšããŠå®çŸå¯èœã§ãã
errors {
404 404.html
}
ç¹å®ã®ã¬ã¹ãã³ã¹ã Caddyfile ã§æå®ã§ããŸããïŒ
Caddy v2 ã§ã¯ respond
ãçšããŠå¯èœã§ãã
ãããããã¡ã€ã«ãçæããå¿
èŠãªããCaddyfile
ã§å®çµã§ããŸãã
 Respond with multi line body | Caddy Forum
robots.txt
ãåç
§ããæã« BOT ãå®å
šæåŠããããã«ããèšå®ã®äŸã§ããCaddyfile
ã¬ãã«ã§ãããåŠçã§ããŸãã
respond /robots.txt 200 {
body "User-agent: *
Disallow: /"
}
確å®ã«ãããããDisallow: /"
ã®é ã«ç©ºçœãå
¥ããªãã§äžããã
Caddyfile ã®èšå®ãä»ã®ãã¡ã€ã«ããå°å ¥ã§ããŸããïŒ
Caddy v2 ã§ã¯ import
ã§å¯èœã§ãããã®è¡ããã¡ã€ã«å
容ã«çœ®ãæããŸãã
äŸãã°èšå®ããŠãããã¡ã€ã³ãå€ãæã«äŸ¿å©ã§ãã
import èªã¿èŸŒããã¡ã€ã«å
Caddyfile
ãã«ã¬ã³ããšããŠçžå¯Ÿæå®ãã§ããŸãã
ãŸã import caddy/*
ã®ããã«ãã¯ã€ã«ãã«ãŒãæå®ãå¯èœã§ãã
.htaccess ãåäœããŠããŸããã
.htaccess
㯠Apache åºæã®èšå®ãã¡ã€ã«ã§ããCaddy ã§ã¯åäœããŸãããCaddyfile
ã«çžåœã®èšå®ãè¿œå ããŠäžããã
403 ãšã©ãŒã«ãªããåç §ã§ããŸããã
å
¬åŒã® Caddy ããã®ãŸãŸäœ¿ã£ãŠ systemd ã§åäœãããå Žåã
caddy ãŠãŒã¶ãŒãçæãããŠããã® caddy ãŠãŒã¶ãŒã§åç
§ãããŸãã
ãã®ãã /home äžã«ãããŠãŒã¶ãŒãã£ã¬ã¯ããªã§
ãã®ãŠãŒã¶ãŒã®ãã£ã¬ã¯ããªã®ããŒããã·ã§ã³ã 700 ã«ãªã£ãŠãããªã©ã
ãŠãŒã¶ãŒä»¥å€ãåç
§ã§ããªãç¶æ
ã«ãªã£ãŠãããš 403 ãšãªããŸãã
ãŠãŒã¶ãŒãã£ã¬ã¯ããªã確èªããŠãããŒãã£ã·ã§ã³ãå€æŽãããã
caddy çšã®å°çšé åãèšããŠããã¡ãã«ãã¡ã€ã«ã眮ãããã«ããŸãã
ãªããCaddy ã¯ãŠãŒã¶ãŒæš©éã§ã®åäœãå¯èœã§ããã
OS ãããŒãžã§ã³ã«ãã£ãŠã¯åäœããªãäºãããã
ãŸãåäœãããšããŠã Caddy ã®æŽæ°ã§ systemd ã®èšå®ãã¡ã€ã«ãæŽæ°ããã
åäœããªããªãå ŽåããããŸãã
PHP 以å€ã®ããã°ã©ãã³ã°èšèªã¯äœ¿çšã§ããŸããïŒ
å€ãã®èšèªã¯äœ¿ããŸããGo ãªã©ã¯ããŒãçªå·ã§ Listen ç¶æ
ã«ã§ããããã
Caddy ã§ã¯ãªããŒã¹ãããã·ãçšããŠãã®ããŒããåç
§ãããŸãã
PHP ã«éããé·å¹Žäœ¿ãããŠãã CMSããã¬ãŒã ã¯ãŒã¯åäœã®èæ
®ã§
Caddy v2 ã§ã¯ php_fastcgi
ãçšæããŠãããŸãã
ã¬ã³ã¿ã«ãµãŒãäŒç€Ÿã®è ã§ããã¬ã³ã¿ã«ãµãŒãåãã«äœ¿çšã§ããŸããïŒ
 Caddy for business | Caddy Forum
ããžãã¹çãªåå¿ãããããã§ãããžãã¹åãã®æ å ±ãå ¬éãã¯ãããŠããŸãã
 Serving tens of thousands of domains over HTTPS with Caddy | Caddy Forum
å
·äœçãªèšå®ã®ãã³ããå
¬éãããŠããŸãã
ãã®ããã¥ã¡ã³ãã«ããããšãããCaddy ãç¶ç¶ããŠäœ¿çšããè¯ããã®ã«ããããã«ã
Caddy ã®ã¹ãã³ãµãŒã«ãªãäºãæ€èšããŠäžããã
ãã©ã°ã€ã³ã»ã¢ãžã¥ãŒã«ã£ãŠäœã§ããïŒ
Caddy ã§ã¯æ©èœãæ¡åŒµã§ããæ段ãååšããŸãã
Caddy v2 ã§ã¯ ã¢ãžã¥ãŒã«ïŒModulesïŒã§ãã
ããŠã³ããŒãããŒãžããã¢ãžã¥ãŒã«ä»ã®ãã€ããªãŒã§ããŠã³ããŒãã§ããããã«ãªããŸããã
Caddy v1 ã§ã¯å
¬åŒããããŠã³ããŒãã®æã«äœ¿çšãããã©ã°ã€ã³ãæå®ããŸãã
äŸãã°æ¬¡ã®ãããªãã©ã°ã€ã³ãååšããŸãã
- tld.dns.ïœ - 蚌ææžçºè¡ãšã㊠HTTP èªèšŒã®ä»£ããã« DNS èªèšŒã䜿çšããŸãã
- dyndns - ãã€ããã㯠DNS ãå®çŸããŸããð Cloudflare ãªã©ã䜿ããŸãã
- http.cgi - CGI åäœãä»å ããŸããïŒãããã Perl ãªã©ãåäœãããŸãïŒ
- http.git - Git ãªããžããªãž push ããŸãã
- minify - 空çœã»æ¹è¡ãåé€ããŸãã
Caddy v1 ã®ãã©ã°ã€ã³ã«ååšããŠããæ©èœã¯
Caddy v2 ã®ã¢ãžã¥ãŒã«ã§é 次éçºãããŠããç¶æ³ã§ãã
ãªããCaddy v1 ã¯ãã©ã°ã€ã³ã«ãã£ãŠãã€ããªãŒãå€åããä»æ§ã ã£ãããã
OS åãã®ããã±ãŒãžã Docker ãå
¬åŒã«è¡ã£ãŠããªãã£ãçµç·¯ããããŸãã
Caddy v2 ã®ã¢ãžã¥ãŒã«ã§ã¯ãã®åé¡ã解決ããŠããããã
å
¬åŒããã±ãŒãžã»å
¬åŒ Docker ãæäŸãããããã«ãªã£ãŠããŠããŸãã