1.3 Caddy Reverse Proxy
I use Caddy as reverse proxy and file server for the different services that I do provide on my server. Caddy is responsible to resolve the subdomains of your main domain and provide the services to your users. Caddy will also automatically take care to assign SSL certificates to your services.
Note
For a detailed documentation pleaser refer to the Caddy website.
To install Caddy on your server simply call
sudo apt install caddy
Caddy uses per default /etc/caddy/Caddyfile
as configuration file.
This configuration file has following content after Caddy has been instelled:
# The Caddyfile is an easy way to configure your Caddy web server.
#
# Unless the file starts with a global options block, the first
# uncommented line is always the address of your site.
#
# To use your own domain name (with automatic HTTPS), first make
# sure your domain's A/AAAA DNS records are properly pointed to
# this machine's public IP, then replace ":80" below with your
# domain name.
:80 {
# Set this path to your site's directory.
root * /usr/share/caddy
# Enable the static file server.
file_server
# Another common task is to set up a reverse proxy:
# reverse_proxy localhost:8080
# Or serve a PHP site through php-fpm:
# php_fastcgi localhost:9000
}
# Refer to the Caddy docs for more information:
# https://caddyserver.com/docs/caddyfile
When you open your web browser and type in the address of your server then Caddy will already show an example website.
To get access to free SSL certificates, the Caddyfile
needs to be extended by your email address.
Please provide your email address as a first statement in the Caddyfile
:
Important
In the Caddyfile always use TABs to indent statements. Spaces will cause format errors.
# The Caddyfile is an easy way to configure your Caddy web server.
#
# Unless the file starts with a global options block, the first
# uncommented line is always the address of your site.
#
# To use your own domain name (with automatic HTTPS), first make
# sure your domain's A/AAAA DNS records are properly pointed to
# this machine's public IP, then replace ":80" below with your
# domain name.
{
email user@example.com
}
:80 {
...
Now you are set up for defining your particular web services. I will explain how to configure Caddy in the section describing the service installation.