Cockpit is a web-based server management tool that provides a user-friendly interface for administrators to manage their servers. In this article, we will walk through the process of setting up Cockpit with Caddy reverse proxy.

Prerequisites

Before we begin, make sure that you have the following:

Step 1: Setup SSL Certificates (Optional)

You can follow the steps for obtaining certificates in Cockpit nginx reverse proxy Put the certificates to a different location, i.e. /etc/caddy/certs Make sure the folder is owned by caddy user if you get permission errors.

Step 2: Setting Up Caddy

Create a new Caddyfile in your server’s configuration directory (usually /etc/caddy/). This file will define the reverse proxy rules for Caddy.

In the Caddyfile, add the following lines to define a reverse proxy rule for your Cockpit panel:

panel.example.com {
        reverse_proxy localhost:9090
}

or if you want to manually specify which key to use instead of automatic ssl:

panel.example.com {
        reverse_proxy localhost:9090
        tls /etc/caddy/certs/fullchain.pem /etc/caddy/certs/privkey.pem
}

Save the Caddyfile and restart Caddy to apply the changes. You can use the following command to restart Caddy:

sudo systemctl restart caddy

Step 3: Make Cockpit proxy aware

https://github.com/cockpit-project/cockpit/wiki/Proxying-Cockpit-over-nginx#make-cockpit-proxy-aware

See Also