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:
- Cockpit installed on the server
- Caddy installed on the server (https://caddyserver.com/docs/install)
- A domain name pointing to your server’s IP address
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:
or if you want to manually specify which key to use instead of automatic ssl:
Save the Caddyfile and restart Caddy to apply the changes. You can use the following command to restart Caddy:
Step 3: Make Cockpit proxy aware
https://github.com/cockpit-project/cockpit/wiki/Proxying-Cockpit-over-nginx#make-cockpit-proxy-aware