This note runs through [caddy](https://caddyserver.com), a free tool webserver allowing for reverse-proxy and automatic SSL certifications.
```
 
```toc
style: number
```
 
---
 
### Installation
 
#### Program installation
1.**Pull the software signature key & image**
`echo "deb [trusted=yes] https://apt.fury.io/caddy/ /" | sudo tee -a /etc/apt/sources.list.d/caddy-fury.list`
3.**Install caddy**
`sudo apt update`
`sudo apt install caddy`
Installing caddy will create a default user 'caddy'.
4.**Test install**
Go to the homepage to see the caddy default page.
 
#### Installing php
PHP needs to be enabled for caddy to work.
`sudo add-apt-repository ppa:ondrej/php`
`sudo apt install php-cli php-fpm php-mysql`
Check if php is installed correctly:
`php --version`
 
---
 
### Configuration of caddy
 
Caddy will fetch a **SSL certificate** for all sub-domains and addresses present in the config file automatically, once the declaration is made properly.
 
#### Basic files & directories
1. Create a default website folder
`sudo mkdir -p /var/www/html`
2. Create a default log folder
`sudo mkdir /var/log/caddy`
`sudo chown -R caddy:caddy /var/log/caddy`
 
#### Caddy configuration file
Caddy's configuration file is inder:
`/etc/caddy/Caddyfile`
Default configuration is:
>(localhost) {
>root * /var/www/html
>encode gzip zstd
>php_fastcgi unix//run/php/php7.4-fpm.sock
>tls (service email) {
>protocols tls1.2 tls1.3
>}
>}
 
#### PHP configuration file
To update php, edit the following file:
`sudo nano /etc/php/7.4/fpm/pool.d/www.conf`
Change all 'www-data' user reference with 'caddy' including:
```
listen.owner = caddy
listen.group = caddy
```
Once this is done, restart php:
`sudo systemctl restart php7.4-fpm`
 
#### Configuration with the docker network
Configuration of a service attached to the docker network is easy: