How to do a basic configuration on Caddy v2 Web Server

Oct 7, 2022

Default Path:

sudo nano /etc/caddy/CaddyFile

Redirect with HTTP:

tutorial.itbible.org:80 {
    redir https://google.com permanent
}

Redirect with HTTPS:

tutorial.itbible.org:443 {
    redir https://google.com permanent
}

Reverse Proxy (Forces HTTPS with HTTP redirects to HTTPS):

tutorial.itbible.org {
    reverse_proxy https://localhost:81
}

Basic HTML Web Page:

tutorial.itbible.org {
    root * /var/www/basic/
    file_server
}

Dynamic PHP Web Page (with PHP8.1-FPM):

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}
}
WizardTux

WizardTux

Father, Veteran, HomeLab User, Tech Enthusiast, Open Source Advocate, Network Engineer, Content Creator, Developer. Thoughts are my own.

0 Comments

Submit a Comment