Partner Content How to do a basic configuration on Caddy v2 Web Server

  • Welcome to ITBible, we're your #1 resource for enterprise or homelab IT problems (or just a place to show off your stuff).
This content was added by a IT Bible partner. See more information about our partner program here.

Code excerpts from video.

Default path:
Bash:
> sudo nano /etc/caddy/CaddyFile

Redirect with HTTP:
Bash:
tutorial.itbible.org:80 {
    redir https://google.com permanent
}

Redirect with HTTPS:
Bash:
tutorial.itbible.org:443 {
    redir https://google.com permanent
}

Reverse Proxy (Forces HTTPS with HTTP redirect to HTTPS):
Bash:
tutorial.itbible.org {
    reverse_proxy https://localhost:81
}

Basic HTML Web Page:
Bash:
tutorial.itbible.org {
    root * /var/www/basic/
    file_server
}

Dynamic PHP Web Page (with PHP8.1-FPM):
Bash:
tutorial.itbible.org {
    root * /var/www/php/
    file_server

    php_fastcgi unix//var/run/php/php8.1-fpm.sock

    try_files {path} /index.php?{query}
}