Autore: Fabio Di Matteo
Ultima revisione: 30/06/2026 14:10
Alcuni appunti su Caddy web server.
Vogliamo avviare caddy server da utente non privilegiato, ma vogliamo che resti in ascolto su porte privilegiate.
setcap 'cap_net_bind_service=+ep' /usr/sbin/caddy su - caddy -s /bin/sh -c "caddy --config /etc/caddy/Caddyfile start"
Richiede PHP-FPM configurato e avviato con lo stesso utente che usa Caddy.
mysite:443 {
root * /var/web/
encode
file_server
php_fastcgi unix//opt/php.sock
log {
level ERROR
output file /var/log/caddy/error.log {
roll_size 10mb
roll_keep 5
roll_keep_for 336h
}
}
#inserire qui , eventualmente le direttive sottostanti
}
...
handle_path /myapp/* {
root * /opt/web/myapp
try_files {path} {path}/ /index.php?{query}
encode gzip
php_fastcgi unix//opt/php85.sock
file_server
}
La direttiva try_files fa si che se nn trova file, oppure cartelle con il nome della nostra richiesta allora smista a /myproject/index.php
...
route /phpmyadmin* {
respond "Oh no..."
}
...
handle /images/*.php {
respond "Php Forbidden."
}
In cima al file di configurazione. Sezione globale.
{
http_port 880
https_port 84443
}
...
route /apps/* {
reverse_proxy localhost:6789
}
...
Ricordarsi di abilitare la rotta /apps anche sulla nostra applicazione locale
...
handle /myapp* {
reverse_proxy localhost:3000 {
transport http {
dial_timeout 2s
response_header_timeout 10s
}
}
}
...
il server dietro proxy deve rispondere entro 2 secondi a una richiesta e non puo' impiegare piu' di 10 secondi per ritornare una risposta.