Installing Cockpit on Debian nameserver with NGINX
user: Let's install RedHat cockpit on our new Debian 13 new primary nameserver ns0.mcwai.net
as you recall, we were going to make it be cockpit.mcwai.net
so, I need you to roll this all out
assistant: Got it 🚀 — let’s roll out **Cockpit** on your new Debian 13 primary nameserver (`ns0.mcwai.net`) and make it available at **https://cockpit.mcwai.net** with SSL.
We’ll do this cleanly with NGINX reverse proxy, IPv4 + IPv6, and DNS under your existing `mcwai.net` zone.
---
## ✅ Deployment Plan
1. **Install Cockpit** (Debian 13)
2. **Enable Cockpit socket** (systemd service on port `9090`)
3. **Set up NGINX reverse proxy** → `cockpit.mcwai.net`
4. **Configure Certbot SSL** (Let’s Encrypt)
5. **Update DNS zone** (`A` + `AAAA` for `cockpit.mcwai.net`)
6. **Open firewall ports** (if needed)
---
## 1. Install Cockpit
```bash
sudo apt update && sudo apt install -y cockpit
```
Enable + start the service:
```bash
sudo systemctl enable --now cockpit.socket
```
Check status:
```bash
systemctl status cockpit.socket
```
Should be listening on `9090` (localhost or all interfaces).
---
## 2. Configure NGINX Reverse Proxy
We’ll run Cockpit **behind NGINX** so it’s accessible at `https://cockpit.mcwai.net` instead of `:9090`.
```bash
sudo nano /etc/nginx/sites-available/cockpit.mcwai.net.conf
```
Content:
```nginx
server {
listen 80;
listen [::]:80;
server_name cockpit.mcwai.net;
location / {
proxy_pass http://127.0.0.1:9090;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# WebSocket support
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
```
Enable + test:
```bash
sudo ln -s /etc/nginx/sites-available/cockpit.mcwai.net.conf /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx
```
---
## 3. SSL with Let’s Encrypt
```bash
sudo apt install -y certbot python3-certbot-nginx
sudo certbot --nginx -d cockpit.mcwai.net
```
Auto-renew is handled by systemd timer:
```bash
systemct…
user: i dont think we have NGINX installed yet. we only have Bind9 installed and configured without TISG so far. we havnt installed much anything else yet
assistant: perfect — since ns0 is still a clean Debian 13 box with only BIND9, here’s a **one‑shot rollout** that installs Cockpit, NGINX, puts Cockpit behind a secure reverse proxy at **https://cockpit.mcwai.net**, forces IPv4 **and** IPv6, and only requests the TLS cert once DNS is pointed correctly.
> Runs end‑to‑end with your preferred flow (nano → chmod → run, single line). It also binds Cockpit to **127.0.0.1:9090** so it’s *not* exposed directly.
---
### 🚀 One‑shot installer (paste this exactly)
```bash
nano /home/adam/scripts/deploy-cockpit-nginx.sh && chmod +x /home/adam/scripts/deploy-cockpit-nginx.sh && /home/adam/scripts/deploy-cockpit-nginx.sh
```
**Script content (paste into nano):**
```bash
#!/usr/bin/env bash
# Deploy Cockpit on Debian 13 behind NGINX at https://cockpit.mcwai.net
# Author: ChatGPT — ns0 rollout
set -euo pipefail
DOMAIN="cockpit.mcwai.net"
SITE_CONF="/etc/nginx/sites-available/${DOMAIN}.conf"
SYSTEMD_DIR="/etc/systemd/system"
COCKPIT_SOCKET_DIR="${SYSTEMD_DIR}/cockpit.socket.d"
COCKPIT_SOCKET_DROPIN="${COCKPIT_SOCKET_DIR}/listen.conf"
# Update these if ns0’s public IPs change:
NS0_V4="5.161.95.125"
NS0_V6="2a01:4ff:f0:6c4b::1"
say() { printf "%s %s\n" "$1" "$2"; }
say "🧰" "Installing Cockpit + NGINX + Certbot… (sudo required)"
sudo apt-get update -y
sudo apt-get install -y cockpit nginx certbot python3-certbot-nginx
say "🔌" "Enabling Cockpit socket"
sudo systemctl enable --now cockpit.socket
# Bind cockpit ONLY to localhost:9090 for safety (reverse proxy only)
say "🔒" "Restricting Cockpit to 127.0.0.1:9090 via systemd drop-in"
sudo install -d -m 0755 "${COCKPIT_SOCKET_DIR}"
# Create drop-in; clears default ListenStream and sets to localhost
sudo tee "${COCKPIT_SOCKET_DROPIN}" >/dev/null <<'INI'
[Socket]
# Clear any existing ListenStream lines from the main unit:
ListenStream=
ListenStream=127.0.0.1:9090
INI
sudo systemctl daemon-reload
sudo systemctl restart cockpit.socket
# NGINX reverse proxy (HTTP first; certbot will upgrade …
user: i have a problem, i cant paste all that in the terminal anymore. When we do it with our previous Ubuntu servers, it was not a problem to paste your scripts. but with this Debian 13 it gets cut off. I'm using Teminator as my terminal on my Ubuntu laptop. maybe there is something we can change, it would be good
assistant: ahh yep — I know exactly what you’re running into 👍
Debian 13 doesn’t limit pasting, but **your terminal emulator + shell buffer** will choke if you paste a very large block all at once. Ubuntu’s GNOME terminal usually swallows big pastes fine, but **Terminator** has stricter line buffer limits — it will cut off mid-script.
Here are a few ways around it:
---
### 🥇 Option 1: Send script as a file (preferred)
Instead of pasting the whole blob:
```bash
cat <<'EOF' > /home/adam/scripts/deploy-cockpit-nginx.sh
# (paste entire script here safely)
EOF
chmod +x /home/adam/scripts/deploy-cockpit-nginx.sh
/home/adam/scripts/deploy-cockpit-nginx.sh
```
Because `cat <<EOF` captures everything until the closing `EOF`, the terminal doesn’t break on huge pastes — it just streams into the file.
---
### 🥈 Option 2: Use `scp` or `sftp`
From your Ubuntu laptop:
```bash
scp deploy-cockpit-nginx.sh adam@ns0.mcwai.net:/home/adam/scripts/
ssh adam@ns0.mcwai.net "chmod +x /home/adam/scripts/deploy-cockpit-nginx.sh && /home/adam/scripts/deploy-cockpit-nginx.sh"
```
That way you edit locally in VS Code/nano and just upload.
---
### 🥉 Option 3: Curl from a pastebin / gist
- Put the script on GitHub Gist or pastebin.
- Then on ns0:
```bash
curl -fsSL https://example.com/deploy-cockpit-nginx.sh -o /home/adam/scripts/deploy-cockpit-nginx.sh
chmod +x /home/adam/scripts/deploy-cockpit-nginx.sh
/home/adam/scripts/deploy-cockpit-nginx.sh
```
---
### 🛠️ Fix Terminator directly
- In Terminator → **Preferences → Profiles → Scrolling**, raise the scrollback buffer from the default (10,000 lines) to something like **100,000**.
- Also disable “Bracketed paste mode” if it’s breaking long streams.
- Or switch temporarily to plain **GNOME Terminal** or `tmux` on the server (`apt install tmux`) — both can handle giant pastes with no cutoffs.
---
👉 My recommendation: **Option 1 (cat <<EOF)** is the most foolproof.
Do you want me to rewrite the Cockpit installer in that compact `cat…
user: nevermind, i use Gnome terminal it works so much better than that Terminator is so smooth
now give me a commands to first run on ns0 to add the zone, then the command we do on ns3 for the bind9 dns zone for cockpit 86400 IN A 5.161.95.125
cockpit 86400 IN AAAA 2a01:4ff:f0:6c4b::1
adam@ns0:~$ mkdir scripts
adam@ns0:~$ ls
ns0-nsd-setup.sh nsd-fix-out-of-zone.sh scripts
adam@ns0:~$ nano /home/adam/scripts/deploy-cockpit-nginx.sh && chmod +x /home/adam/scripts/deploy-cockpit-nginx.sh && /home/adam/scripts/deploy-cockpit-nginx.sh
🧰 Installing Cockpit + NGINX + Certbot… (sudo required)
Hit:1 http://mirror.hetzner.com/debian/packages trixie InRelease
Hit:2 http://mirror.hetzner.com/debian/packages trixie-updates InRelease
Hit:3 http://mirror.hetzner.com/debian/packages trixie-backports InRelease
Hit:4 http://mirror.hetzner.com/debian/security trixie-security InRelease
Hit:5 http://deb.debian.org/debian trixie InRelease
Hit:6 http://deb.debian.org/debian trixie-updates InRelease
Hit:7 http://deb.debian.org/debian trixie-backports InRelease
Hit:8 http://deb.debian.org/debian-security trixie-security InRelease
Reading package lists... Done
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
cockpit is already the newest version (337-1).
The following additional packages will be installed:
nginx-common python3-acme python3-certbot python3-configargparse python3-josepy python3-openssl
python3-parsedatetime python3-pyparsing python3-pytz python3-rfc3339
Suggested packages:
python-certbot-doc python3-certbot-apache fcgiwrap nginx-doc ssl-cert python-acme-doc
python-certbot-nginx-doc python-openssl-doc python-pyparsing-doc
Recommended packages:
python3-icu
The following NEW packages will be installed:
certbot nginx nginx-common python3-acme python3-certbot python3-certbot-nginx python3-configargparse
python3-josepy python3-openssl python3-parsedatetime python3-pyparsing python3-pytz python3-rfc33…
assistant: Nice 👍 everything on **ns0** looks good — Cockpit is live behind NGINX, just waiting on DNS.
Now let’s drop in the **zone records** and reload so that `cockpit.mcwai.net` resolves correctly.
---
## 🖥️ On **ns0** (primary BIND9)
Edit your zone file for `mcwai.net`.
Example if it’s at `/etc/bind/zones/db.mcwai.net`:
```bash
sudo nano /etc/bind/zones/db.mcwai.net
```
Add these lines under the other host records (before the last `;` if you keep comments):
```
cockpit 86400 IN A 5.161.95.125
cockpit 86400 IN AAAA 2a01:4ff:f0:6c4b::1
```
Then **increment the SOA serial** at the top of the zone (just bump by +1).
Example:
```
@ IN SOA ns0.mcwai.net. hostmaster.mcwai.net. (
2025082101 ; serial <── bump this
86400 ; refresh
7200 ; retry
3600000 ; expire
86400 ) ; minimum
```
Save → reload BIND:
```bash
sudo rndc reload mcwai.net
```
Check:
```bash
dig @127.0.0.1 cockpit.mcwai.net A +short
dig @127.0.0.1 cockpit.mcwai.net AAAA +short
```
Should print:
```
5.161.95.125
2a01:4ff:f0:6c4b::1
```
---
## 🖥️ On **ns3** (secondary)
Since ns3 is slaving `mcwai.net` from ns0, you just tell it to refresh:
```bash
sudo rndc refresh mcwai.net
```
Then confirm:
```bash
dig @127.0.0.1 cockpit.mcwai.net A +short
dig @127.0.0.1 cockpit.mcwai.net AAAA +short
```
---
## 🌐 From outside
After propagation, test from your laptop:
```bash
dig cockpit.mcwai.net A +short
dig cockpit.mcwai.net AAAA +short
```
When both resolve, run on **ns0** to finish TLS:
```bash
sudo certbot --nginx -d cockpit.mcwai.net
```
---
Do you want me to also whip up a **serial-bump helper script** for ns0 so that adding A/AAAA records in the future is safer and you don’t have to hand-edit the serial each time?
user: no, i dont need a serial bumper script
everything is working fine
now cockpit resolves ready to work your magic
assistant: 💯 perfect — since `cockpit.mcwai.net` now resolves over both IPv4 + IPv6, the only step left is to grab the SSL cert and flip Cockpit to HTTPS through NGINX.
Run this on **ns0**:
```bash
sudo certbot --nginx -d cockpit.mcwai.net
```
It will:
- Request a Let’s Encrypt cert
- Auto-configure NGINX to serve `https://cockpit.mcwai.net`
- Reload NGINX
---
### ✅ Verify afterwards
1. Check NGINX picked up TLS:
```bash
sudo nginx -t && sudo systemctl reload nginx
```
2. Open in browser:
👉 [https://cockpit.mcwai.net](https://cockpit.mcwai.net)
3. Test from CLI:
```bash
curl -vkI https://cockpit.mcwai.net
```
Should return `HTTP/1.1 200 OK` and show a valid cert.
---
### 🔒 Optional hardening
You can add HSTS so browsers always use HTTPS:
```bash
sudo sed -i '/ssl_prefer_server_ciphers on;/a \\tadd_header Strict-Transport-Security "max-age=63072000; includeSubDomains" always;' /etc/nginx/sites-enabled/cockpit.mcwai.net.conf
sudo nginx -t && sudo systemctl reload nginx
```
---
Would you like me to also wire in **firewall rules** (UFW or nftables) so Cockpit is *only* reachable via NGINX 443, and nothing can ever hit port `9090` externally?
user: are you sure NGINX is installed?
assistant: Yep 👍 I can tell from the output you shared earlier on **ns0** — the installer script already pulled it in.
Here’s the proof right from your logs:
```
The following NEW packages will be installed:
certbot nginx nginx-common ...
...
Setting up nginx (1.26.3-3) ...
Upgrading binary: nginx.
```
and later:
```
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
NGINX ✅ syntax OK
```
So NGINX **is installed and running** right now on ns0. ✅
If you want to double-check, run:
```bash
nginx -v
systemctl status nginx
ss -tlnp | grep nginx
```
That’ll confirm the version (should show `1.26.3-3`), service status, and which ports it’s listening on (80 and 443).
👉 Do you want me to go ahead and give you the exact certbot command now to flip `cockpit.mcwai.net` to HTTPS?
user: well, you know things on Debain 13 a little different. command not found
adam@ns0:/etc/bind/zones$ nginx -v
-bash: nginx: command not found
adam@ns0:/etc/bind/zones$
systemctl status nginx
ss -tlnp | grep nginx
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; preset: en>
Active: active (running) since Thu 2025-08-21 06:28:41 UTC; 12min ago
Invocation: dd4e9ebb10134acda0b202f120adf4aa
Docs: man:nginx(8)
Process: 2517 ExecReload=/usr/sbin/nginx -g daemon on; master_process on; ->
Main PID: 2303 (nginx)
Tasks: 4 (limit: 4555)
Memory: 3.8M (peak: 8.9M)
CPU: 56ms
CGroup: /system.slice/nginx.service
├─2303 "nginx: master process /usr/sbin/nginx -g daemon on; master>
├─2519 "nginx: worker process"
├─2520 "nginx: worker process"
└─2521 "nginx: worker process"
adam@ns0:/etc/bind/zones$ sudo certbot --nginx -d cockpit.mcwai.net
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Enter email address or hit Enter to skip.
(Enter 'c' to cancel): adam76@mailfence.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at:
https://letsencrypt.org/documents/LE-SA-v1.5-February-24-2025.pdf
You must agree in order to register with the ACME server. Do you agree?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: yes
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing, once your first certificate is successfully issued, to
share your email address with the Electronic Frontier Foundation, a founding
partner of the Let's Encrypt project and the non-profit organization that
develops Certbot? We'd like to send you email about our work encrypting the web,
EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - -…
assistant: Got it — Certbot’s error is a classic “port 80 not reachable from the internet.” NGINX is running, but inbound 80/443 are likely blocked (UFW/nftables or provider firewall). Let’s fix and finish the cert.
### 1) Quick checks (DNS + listeners)
Run on **your laptop** (or anywhere on the internet):
```bash
dig +short cockpit.mcwai.net A
dig +short cockpit.mcwai.net AAAA
```
Run on **ns0**:
```bash
sudo ss -ltnp '( sport = :80 or sport = :443 )'
sudo tail -n +1 /etc/nginx/sites-enabled/*.conf | sed -n '1,80p'
```
You should see NGINX listening on `0.0.0.0:80` and `[::]:80`.
### 2) Open ports on ns0 (UFW or nftables)
**If UFW is active:**
```bash
sudo ufw status verbose
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw reload
sudo ufw status numbered
```
**If UFW is inactive, check nftables:**
```bash
sudo systemctl status nftables
sudo nft list ruleset | sed -n '1,200p'
```
If nftables is dropping by default, add an allow rule:
```bash
sudo nft add rule inet filter input tcp dport {80,443} ct state new accept
sudo nft list ruleset | sed -n '1,200p'
```
### 3) Check provider firewall (Hetzner Cloud)
In the Hetzner project, make sure the server firewall (if enabled) allows:
- TCP 80 (IPv4/IPv6) from `0.0.0.0/0` and `::/0`
- TCP 443 (IPv4/IPv6) from `0.0.0.0/0` and `::/0`
### 4) Re-test reachability and issue cert
From your laptop:
```bash
curl -I http://cockpit.mcwai.net
```
Expect `HTTP/1.1 200 OK` (or a 301).
Then on **ns0**:
```bash
sudo certbot --nginx -d cockpit.mcwai.net
sudo nginx -t && sudo systemctl reload nginx
```
### 5) Verify HTTPS
```bash
curl -vkI https://cockpit.mcwai.net
```
### Bonus: about `nginx -v` “command not found”
That’s just PATH — Debian keeps `nginx` in `/usr/sbin`, which isn’t in an unprivileged user’s PATH. Use:
```bash
sudo /usr/sbin/nginx -v
# or
sudo nginx -v
```
Ping me with the outputs of steps 1–2 if the cert still fails — we’ll zero in fast.
user: xenon@Latitude:~$ curl -I http://cockpit.mcwai.net
HTTP/1.1 200 OK
Server: nginx
Date: Thu, 21 Aug 2025 06:45:44 GMT
Content-Type: text/html
Connection: keep-alive
Content-Security-Policy: connect-src 'self' http://cockpit.mcwai.net ws://cockpit.mcwai.net; form-action 'self' http://cockpit.mcwai.net; base-uri 'self' http://cockpit.mcwai.net; object-src 'none'; font-src 'self' http://cockpit.mcwai.net data:; img-src 'self' http://cockpit.mcwai.net data:; block-all-mixed-content; default-src 'self' http://cockpit.mcwai.net 'unsafe-inline'
Set-Cookie: cockpit=deleted; PATH=/; SameSite=strict; HttpOnly
Cache-Control: no-cache, no-store
X-DNS-Prefetch-Control: off
Referrer-Policy: no-referrer
X-Content-Type-Options: nosniff
Cross-Origin-Resource-Policy: same-origin
X-Frame-Options: sameorigin
xenon@Latitude:~$
adam@ns0:/etc/bind/zones$ sudo ufw status verbose
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw reload
sudo ufw status numbered
Status: active
Logging: on (low)
Default: deny (incoming), allow (outgoing), disabled (routed)
New profiles: skip
To Action From
-- ------ ----
53/tcp ALLOW IN Anywhere
53/udp ALLOW IN Anywhere
47122/tcp ALLOW IN Anywhere # SSH
53/tcp (v6) ALLOW IN Anywhere (v6)
53/udp (v6) ALLOW IN Anywhere (v6)
47122/tcp (v6) ALLOW IN Anywhere (v6) # SSH
Rule added
Rule added (v6)
Rule added
Rule added (v6)
Firewall reloaded
Status: active
To Action From
-- ------ ----
[ 1] 53/tcp ALLOW IN Anywhere
[ 2] 53/udp ALLOW IN Anywhere
[ 3] 47122/tcp ALLOW IN Anywhere # SSH
[ 4] 80/tcp …
assistant: Good news: HTTPS is set up and live. The “Could not resolve host” you saw on **ns0** is just a **local DNS resolver** issue on that box — not a site problem. Since ns0 is running BIND9 as **authoritative-only** (no recursion), the server itself can’t resolve names unless you point it at a recursive resolver (or run one locally). Your laptop curl already showed 200 OK over HTTP, and Certbot succeeded, so the site is reachable from the internet.
Here’s the quick path + the clean, persistent fix.
---
## Quick verification without DNS (on ns0)
This hits NGINX/Cockpit directly and uses the vhost name:
```bash
# TLS path, skip certificate check (-k) and set Host header
curl -kI https://127.0.0.1 -H 'Host: cockpit.mcwai.net'
```
You should get `HTTP/1.1 200 OK`.
---
## Option A — Temporary resolver (fastest)
Point ns0 to external recursive resolvers just to make local lookups work:
```bash
sudo bash -c 'printf "nameserver 1.1.1.1\nnameserver 9.9.9.9\n" > /etc/resolv.conf'
# test:
getent hosts cockpit.mcwai.net
curl -I https://cockpit.mcwai.net
```
Note: this may be overwritten by your network manager on reboot.
---
## Option B — Persistent via systemd‑resolved (clean)
1) Check if systemd‑resolved is in use:
```bash
resolvectl status
```
2) Set global DNS and flush:
```bash
sudo mkdir -p /etc/systemd
sudo tee /etc/systemd/resolved.conf >/dev/null <<'CONF'
[Resolve]
DNS=1.1.1.1 9.9.9.9
FallbackDNS=1.0.0.1 149.112.112.112
Domains=mcwai.net
MulticastDNS=no
LLMNR=no
Cache=yes
DNSSEC=no
CONF
sudo systemctl restart systemd-resolved
sudo resolvectl flush-caches
# point /etc/resolv.conf to systemd stub if needed:
if [ -L /etc/resolv.conf ]; then ls -l /etc/resolv.conf; else sudo ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf; fi
# test:
getent hosts cockpit.mcwai.net
curl -I https://cockpit.mcwai.net
```
---
## Option C — Best practice: local recursive cache (Unbound)
If you prefer keeping BIND9 authoritative‑only (good practice), add a tiny local resolver:…
user: its fine for now, lets move forward with getting cockpit running
adam@ns0:~$ # TLS path, skip certificate check (-k) and set Host header
curl -kI https://127.0.0.1 -H 'Host: cockpit.mcwai.net'
HTTP/1.1 200 OK
Server: nginx
Date: Thu, 21 Aug 2025 06:49:10 GMT
Content-Type: text/html
Connection: keep-alive
Content-Security-Policy: connect-src 'self' http://cockpit.mcwai.net ws://cockpit.mcwai.net; form-action 'self' http://cockpit.mcwai.net; base-uri 'self' http://cockpit.mcwai.net; object-src 'none'; font-src 'self' http://cockpit.mcwai.net data:; img-src 'self' http://cockpit.mcwai.net data:; block-all-mixed-content; default-src 'self' http://cockpit.mcwai.net 'unsafe-inline'
Set-Cookie: cockpit=deleted; PATH=/; SameSite=strict; HttpOnly
Cache-Control: no-cache, no-store
X-DNS-Prefetch-Control: off
Referrer-Policy: no-referrer
X-Content-Type-Options: nosniff
Cross-Origin-Resource-Policy: same-origin
X-Frame-Options: sameorigin
adam@ns0:~$ resolvectl status
-bash: resolvectl: command not found
adam@ns0:~$ sudo bash -c 'printf "nameserver 1.1.1.1\nnameserver 9.9.9.9\n" > /etc/resolv.conf'
# test:
getent hosts cockpit.mcwai.net
curl -I https://cockpit.mcwai.net
2a01:4ff:f0:6c4b::1 cockpit.mcwai.net
HTTP/1.1 200 OK
Server: nginx
Date: Thu, 21 Aug 2025 06:50:43 GMT
Content-Type: text/html
Connection: keep-alive
Content-Security-Policy: connect-src 'self' http://cockpit.mcwai.net ws://cockpit.mcwai.net; form-action 'self' http://cockpit.mcwai.net; base-uri 'self' http://cockpit.mcwai.net; object-src 'none'; font-src 'self' http://cockpit.mcwai.net data:; img-src 'self' http://cockpit.mcwai.net data:; block-all-mixed-content; default-src 'self' http://cockpit.mcwai.net 'unsafe-inline'
Set-Cookie: cockpit=deleted; PATH=/; SameSite=strict; HttpOnly
Cache-Control: no-cache, no-store
X-DNS-Prefetch-Control: off
Referrer-Policy: no-referrer
X-Content-Type-Options: nosniff
Cross-Origin-Resource-Policy: same-origin
X-Frame-Options: sameorigin
adam@ns0:~$
assistant: awesome — DNS + TLS are good and Cockpit is answering. Let’s finish by tightening the proxy + enabling the good Cockpit add‑ons so the UI is fully functional.
## 1) Patch NGINX headers + Cockpit reverse‑proxy hints
This fixes minor “http://” bits in the CSP and makes Cockpit fully aware it’s behind HTTPS.
```bash
nano /home/adam/scripts/harden-cockpit-proxy.sh && chmod +x /home/adam/scripts/harden-cockpit-proxy.sh && /home/adam/scripts/harden-cockpit-proxy.sh
```
Paste into nano:
```bash
#!/usr/bin/env bash
set -euo pipefail
SITE="/etc/nginx/sites-enabled/cockpit.mcwai.net.conf"
# Ensure correct proxy headers (host, proto, port) for Cockpit behind TLS
sudo awk '
/location \//,/\}/ {
if ($0 ~ /proxy_set_header Host /) seen["Host"]=1
if ($0 ~ /proxy_set_header X-Forwarded-Host /) seen["XFH"]=1
if ($0 ~ /proxy_set_header X-Forwarded-Proto /) seen["XFP"]=1
if ($0 ~ /proxy_set_header X-Forwarded-Port /) seen["XFPo"]=1
}
{ print }
END {
if (!seen["XFH"]) print " proxy_set_header X-Forwarded-Host $host;";
if (!seen["XFP"]) print " proxy_set_header X-Forwarded-Proto https;";
if (!seen["XFPo"]) print " proxy_set_header X-Forwarded-Port 443;";
}
' "$SITE" | sudo tee "$SITE".tmp >/dev/null && sudo mv "$SITE".tmp "$SITE"
# Cockpit reverse proxy hints
sudo install -d -m0755 /etc/cockpit
sudo tee /etc/cockpit/cockpit.conf >/dev/null <<'CONF'
[WebService]
# Let Cockpit accept and generate HTTPS/WSS behind a reverse proxy
Origins = https://cockpit.mcwai.net wss://cockpit.mcwai.net
ProtocolHeader = X-Forwarded-Proto
ForwardedForHeader = X-Forwarded-For
# (Optional) If you ever put it on a subpath, set UrlRoot=/subpath
CONF
# Reload services
sudo nginx -t && sudo systemctl reload nginx
sudo systemctl restart cockpit.socket
echo "✅ Hardened headers + proxy hints applied."
```
Quick check:
```bash
curl -I https://cockpit.mcwai.net
```
---
## 2) Install Cockpit add‑ons (metrics, storage, sosreport)
These make the dashboard actually useful (g…
user: i logged in cockpit just fine, ssl cert is fine. now ill start a new chat thread on what I want to work on next
assistant: 🎉 excellent — Cockpit is live, behind NGINX, on HTTPS, and your login works. That means **ns0 is fully ready for management through the browser**.
Perfect point to wrap this rollout. ✅
I’ll wait for your new thread on what you’d like to tackle next.
Showing first 20 of 20 messages. View the full conversation at https://mcwai.org/ai-conversation/installing-cockpit-on-debian-nameserver-with-nginx