HTTPS

Netlens itself speaks plain HTTP on port 8080. Passwords, sessions and (if you use the web terminal) SSH passwords then travel unencrypted, so on a network where others could listen in, or if you open Netlens from outside, put it behind a reverse proxy that does HTTPS. Use a proxy that can keep WebSocket connections open (the web terminal needs them) and that passes the original Host header. When a request arrives over HTTPS (the proxy sends X-Forwarded-Proto: https), Netlens marks its session cookie Secure by itself. Do not forward Netlens straight to the internet without HTTPS and strong passwords.

If the proxy runs on the same device as Netlens (a Synology’s built-in one, Caddy, nginx), add NETLENS_BIND=127.0.0.1:8080 to the environment so that only the proxy can reach Netlens. If the proxy runs in its own container (Nginx Proxy Manager, Traefik), leave the default and point the proxy at http://<device-ip>:8080.

Synology (built-in reverse proxy): 1. Control Panel → Security → Certificate: get or import a certificate for the name you will use (for example netlens.example.com, or a Let’s Encrypt one via your DDNS name). 2. Control Panel → Login Portal → Advanced → Reverse Proxy → Create: source HTTPS, that host name, port 443; destination HTTP, localhost, port 8080. 3. Edit the rule → Custom Header → Create → WebSocket (adds the headers the terminal needs). Then assign the certificate to the rule under Security → Certificate → Settings.

Caddy (gets and renews the certificate itself): a Caddyfile of

netlens.example.com {
    reverse_proxy 127.0.0.1:8080
}

nginx:

location / {
    proxy_pass http://127.0.0.1:8080;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_read_timeout 3600s;   # long web terminal sessions
}

Nginx Proxy Manager: Proxy Hosts → Add: scheme http, forward host the device’s IP, port 8080, switch Websockets Support on, and request a certificate on the SSL tab (tick Force SSL).

Traefik: route the host name to http://<device-ip>:8080 with TLS on the router; WebSockets work without extra settings.

For the installable app (see Installing Netlens as an app): – The certificate must be trusted by the device (Let’s Encrypt or your own CA installed on it). With a self-signed certificate the browser refuses the service worker, so there is no install option. – Do not switch on the proxy’s own caching of static files (Nginx Proxy Manager: Cache Assets; Cloudflare: cache rules for the site). Netlens sends Cache-Control: no-cache so that an update shows at once, and an extra cache would keep serving the old sw.js and interface files. – If something in front of Netlens asks for a login (Authelia, Authentik, Cloudflare Access, basic auth), it must also let /manifest.webmanifest, /sw.js and /img/* through, or at least accept the same session for them; otherwise the browser cannot read the manifest and silently offers no install. Netlens has its own login, so the simplest setup is no second login in front of it. – Keep the path as it is: Netlens works under a sub-path (https://example.com/netlens/) as long as the proxy strips the prefix.

Things to know: behind a proxy every request comes from the proxy’s address, so the login rate limit then counts per user name instead of per address; Home Assistant and Prometheus use the same HTTPS address (Home Assistant: Reconfigure; tick Verify the TLS certificate when the certificate is a normal one).