Reverse proxying with Caddy on Linux

Welcome to the Caddy reverse proxy guide. Note that this guide is meant only for Linux users, and that currently there are no options for Windows or Mac. These commands will not work on those OSs, so do not follow this if you are not on a Linux distribution. An SSL certificate will be automatically generated by Caddy at each service start to make your Dashboard secure.

Installing Caddy

  1. Start off by updating your package index.

sudo apt update
  1. Next, install the caddy package.

sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https curl
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
sudo apt install caddy

Set up reverse proxy

Now we need to configure apache to reverse proxy port 42356, or whichever port your webserver is running on.

  1. Create a host configuration file for your domain:

sudo nano /etc/caddy/Caddyfile
  1. Paste the following into the file, replacing your.domain.com with the domain you will be running the Dashboard on. Note that if you are running the webserver on a port other than port 42356, you will need to replace 42356 below with the the specified port.

your.domain.com {
    reverse_proxy :42356
}

Warning

You should use localhost instead of 0.0.0.0 to make the “real” webserver port private, and use the --host localhost cli flag for starting the webserver.

  1. Finally, restart caddy for the changes to take effect.

sudo systemctl restart caddy

Now, if you navigate to your device’s IP, you should be able to see the Dashboard (if the webserver is running).