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 Nginx reverse proxy.
Prerequisites
Before we begin, make sure that you have the following:
- Cockpit installed on the server
- Nginx installed on the server
- A domain name pointing to your server’s IP address
Step 1: Setup SSL Certificates
First, we need to obtain SSL certificates for our domain name. We will use Certbot to obtain SSL certificates. Run the following command to obtain SSL certificates for your domain name.
Make sure to replace example.com
with your domain name.
Next, we need to create a directory to store our SSL certificates. Run the following command to create a directory named ssl
in the /etc/nginx/
directory.
Copy the SSL certificates to the newly created ssl
directory using the following commands.
Make sure to replace example.com
with your domain name.
Step 2: Setting Up Nginx
Now, we need to create an Nginx configuration file for Cockpit. Run the following command to create a new file named cockpit.conf
in the /etc/nginx/sites-available/
directory.
Enter the following configuration into the cockpit.conf
file.
We need to modify the Nginx configuration file to enable the Cockpit configuration we just created. Run the following command to edit the nginx.conf
file.
Add the following line to the http
block.
Create a symbolic link to the Cockpit configuration file we just created using the following command.
Restart the Nginx service to apply the changes we made using the following command.
Step 3: Make Cockpit proxy aware
https://github.com/cockpit-project/cockpit/wiki/Proxying-Cockpit-over-nginx#make-cockpit-proxy-aware