User Tools

Site Tools


computing:cockpit

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
computing:cockpit [2026/10/10 03:05] – oemb1905computing:cockpit [2026/11/12 16:32] (current) – oemb1905
Line 106: Line 106:
 <code> <code>
 [WebService] [WebService]
-Origins = https://domain.com https://domain.com:9090  +AllowUnencrypted = true 
-#wss://domain.com is needed on some setups +Address = 0.0.0.0 
-#ProtocolHeader = X-Forwarded-Proto can be needed in filtered setups+Origins = https://*.haacksnetworking.org http://127.0.0.1:9090 
 +ProtocolHeader = X-Forwarded-Proto 
 +ForwardedForHeader = X-Forwarded-For
 </code> </code>
  
-This instructs Cockpit's internal web socket system to trust the domain/origin and the web socket reverse proxy that we configured in apache (since it differs from the listener on localhost). Restart the server or minimally restart cockpit+apache. Once they are restarted and their status healthy, navigate to ''domain.com'' in a browser and it should redirect to TLS and show the Cockpit landing page. If not, trace over the steps above and fix your work before proceeding. +This instructs Cockpit's internal web socket system to trust the domain/origin and the web socket reverse proxy that we configured in apache (since it differs from the listener on localhost). //Adjust the domain and subdomain wildcard to fit your actual domain//. Restart the server or minimally restart cockpit+apache. Once they are restarted and their status healthy, navigate to ''domain.com'' in a browser and it should redirect to TLS and show the Cockpit landing page. If not, trace over the steps above and fix your work before proceeding. 
  
 === Discussion on Access to Cockpit === === Discussion on Access to Cockpit ===
Line 141: Line 143:
   * [[https://cockpit-project.org/faq.html|Using Cockpit ]]   * [[https://cockpit-project.org/faq.html|Using Cockpit ]]
  
-In conclusion, this tutorial allows for secure web browser access with no browser barf or work arounds. The cert renews on schedule and briefly opens port 80 during that process. If something goes wrong, TLS is ready and secure if ufw or location packages fail. Additionally, since ssh is open by default, one can also simply use the official Cockpit flatpak. However, it's nice to not have to rely on the flatpak and this tutorial solves that. +In conclusion, this tutorial allows for secure web browser access with no browser barf or work arounds. The cert renews on schedule and briefly opens port 80 during that process. If something goes wrong, TLS is ready and secure if ufw or location packages fail. Additionally, since ssh is open by default, one can also simply use the official Cockpit flatpak. However, it's nice to not have to rely on the flatpak and this tutorial solves that. Another thing that users might desire is a custom fail2ban jail that will work with the reverse proxy. First, open and create the filter logic:
  
- --- //[[alerts@haacksnetworking.org|oemb1905]] 2026/10/10 02:57//+<code> 
 +nano /etc/fail2ban/filter.d/cockpit-apache.conf 
 +[Definition] 
 +failregex = ^.*cockpit-session\[\d+\]: pam_unix\(cockpit:auth\): authentication failure; .* rhost=<HOST> .* 
 +ignoreregex = 
 +</code> 
 + 
 +Now, create the jail: 
 + 
 +<code> 
 +nano /etc/fail2ban/jail.local 
 +[cockpit-apache] 
 +enabled      = true 
 +port         = http,https 
 +filter       = cockpit-apache 
 +backend      = systemd 
 +journalmatch = _COMM=cockpit-session 
 +logpath      = /var/log/journal 
 +maxretry     = 3 
 +</code> 
 + 
 +When testing, this might help: 
 + 
 +  fail2ban-client reload --restart --unban cockpit-apache 
 + 
 +The pcp logging tool has a cranky timer: 
 + 
 +  apt install pcp python3-pcp cockpit-bridge 
 +  systemctl enable --now pmlogger.service 
 +  systemctl enable --now pmlogger_daily.timer 
 +  systemctl enable --now pmlogger_check.timer 
 +  systemctl restart pmlogger 
 +  systemctl status pmlogger_daily.timer 
 +  systemctl list-timers | grep pmlogger 
 +  systemctl reset-failed pmlogger_daily.service 
 + 
 +To increase log retention, open ''nano /etc/pcp/pmlogger/control.d/local'' and then enter something like: 
 + 
 +<code> 
 +$PCP_COMPRESSAFTER=7 
 +LOCALHOSTNAME   y   n   PCP_ARCHIVE_DIR/LOCALHOSTNAME   -r -T90d -c config.default -v 100Mb 
 +</code> 
 + 
 +Once that's done, restart the service with ''systemctl restart pmlogger''. Okay, I also have recipes for setting up one's reverse proxy and fail2ban with nginx. Do something like the following: 
 + 
 +<code> 
 +sudo certbot certonly --standalone \ 
 +  -d assist.domain.com \ 
 +  --pre-hook "systemctl stop nginx" \ 
 +  --post-hook "systemctl start nginx" 
 + 
 +sudo nano /etc/nginx/sites-available/assist.domain.com 
 +# HTTP → HTTPS 
 +server { 
 +    listen 80; 
 +    listen [::]:80; 
 +    server_name assist.domain.com; 
 + 
 +    # allow 96.40.208.144; 
 +    # allow 2601:8c3:8684:a3f1::b2c; 
 +    # deny all; 
 + 
 +    return 301 https://$host$request_uri; 
 +} 
 + 
 +# HTTPS reverse proxy to Cockpit 
 +server { 
 +    listen 443 ssl http2; 
 +    listen [::]:443 ssl http2; 
 +    server_name assist.domain.com; 
 + 
 +    ssl_certificate /etc/letsencrypt/live/assist.domain.com/fullchain.pem; 
 +    ssl_certificate_key /etc/letsencrypt/live/assist.domain.com/privkey.pem; 
 +    include /etc/letsencrypt/options-ssl-nginx.conf; 
 +    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; 
 + 
 +    add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always; 
 + 
 +    # allow 96.40.208.144; 
 +    # allow 2601:8c3:8684:a3f1::b2c; 
 +    # deny all; 
 + 
 +    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; 
 + 
 +        proxy_http_version 1.1; 
 +        proxy_set_header Upgrade $http_upgrade; 
 +        proxy_set_header Connection "upgrade"; 
 +        proxy_buffering off; 
 +        proxy_read_timeout 300s; 
 +        gzip off; 
 +    } 
 +} 
 + 
 +sudo ln -s /etc/nginx/sites-available/assist.domain.com /etc/nginx/sites-enabled/ 
 +sudo nginx -t && sudo systemctl reload nginx 
 +</code> 
 + 
 +Then, for the fail2ban rule, rewrite it as follows: 
 + 
 +<code> 
 +sudo nano /etc/fail2ban/filter.d/cockpit-nginx.conf 
 +[Definition] 
 +failregex = ^<HOST> -.*"(GET|POST|HEAD) .*HTTP.*" 401 
 +ignoreregex = 
 +</code> 
 + 
 +<code> 
 +sudo nano /etc/fail2ban/jail.local 
 +[cockpit-nginx] 
 +enabled  = true 
 +port     = http,https 
 +filter   = cockpit-nginx 
 +logpath  = /var/log/nginx/access.log 
 +maxretry = 2 
 +</code> 
 + 
 + --- //[[alerts@haacksnetworking.org|oemb1905]] 2026/11/12 16:31//
computing/cockpit.1791601508.txt.gz · Last modified: by oemb1905