Skip to content

Set up HTTPS and a reverse proxy

Collectors and scheduler integration need a reachable backend endpoint. This setup provides HTTPS through nginx and precedes configuration of the HTTP sinks.

Install nginx

On the Ubuntu/Debian server used by this guide, root installs nginx through the package manager:

apt-get update
apt-get install -y nginx

Other distributions have their own package and service conventions. An existing server also needs a review of its current nginx sites and occupied ports.

Using nginx

In this setup, nginx provides the HTTPS endpoint and the backend listens only on loopback. The main object in config.json needs these changes:

  • "addr" is set to "127.0.0.1:8443".
  • "https-cert-file" and "https-key-file" are removed.
  • "redirect-http-to" is removed.

The nginx configuration belongs, for example, at /etc/nginx/sites-available/clustercockpit. Its FQDN and certificate paths must match the installation. Certificates come from the organisation's designated process; private keys remain readable only by authorised accounts.

The example file enables HSTS for one year. During initial HTTPS setup, the line containing add_header Strict-Transport-Security must remain commented out. It can be enabled once the hostname, certificate chain, and HTTPS access work reliably for the long term.

Show nginx configuration
server {
    listen 443 ssl;
    listen [::]:443 ssl;

    server_name __FQDN__;

    location = /robots.txt {
        default_type text/plain;
        return 200 "User-agent: *\nDisallow: /\n";
    }

    server_tokens off;
    autoindex off;

    ssl_certificate     /etc/ssl/__PEM_FILE__;
    ssl_certificate_key /etc/ssl/__KEY_FILE__;

    ssl_protocols       TLSv1.2 TLSv1.3;
    ssl_ciphers         HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers on;

    add_header Strict-Transport-Security "max-age=31536000" always;
    add_header X-Content-Type-Options "nosniff" always;
    add_header Referrer-Policy "strict-origin-when-cross-origin" always;
    add_header X-Frame-Options "DENY" always;

    location / {
        limit_except GET POST HEAD {
            deny all;
        }

        proxy_pass         http://127.0.0.1:8443;
        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_read_timeout 90;
    }
}

server {
    listen 80;
    listen [::]:80;
    server_name __FQDN__;
    return 301 https://$host$request_uri;
}

For a new installation, these commands enable the site and start the services. An installation already in use needs the maintenance procedure first. The backend restart applies the changed listen address:

set -eu
ln -s /etc/nginx/sites-available/clustercockpit /etc/nginx/sites-enabled/clustercockpit
nginx -t
systemctl restart clustercockpit.service
systemctl enable --now nginx
systemctl reload nginx

nginx redirects HTTP to HTTPS, terminates TLS, and forwards requests to the local backend. Its security headers limit framing, MIME sniffing, and disclosure of referrer information.

Check HTTPS and API access

Before HTTP sinks are configured, the selected hostname and certificate chain must work from the compute nodes. The same applies to the Slurm management node. A successful HTTPS login confirms access to the web interface. API access also requires a valid backend JWT and matching source addresses in main.api-allowed-ips. This list accepts individual IP addresses, not CIDR ranges.

The example allows GET, POST, and HEAD; the proxy rejects other methods. User configuration, metadata edits, and deletion features may also require PUT, PATCH, and DELETE. For those features, the following policy replaces the existing limit_except line:

limit_except GET POST HEAD PUT PATCH DELETE OPTIONS {
    deny all;
}

Each change needs another nginx -t check and configuration reload. Backend authentication and role checks remain active. A test account must have the intended API access; requests without a JWT must still be rejected by the protected API through the proxy. The backend remains bound to loopback.

Once these checks pass, collector installation can continue.