brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Guide: put Nextcloud behind Nginx Proxy Manager with HTTPS and the right headers

put Nextcloud behind Nginx Proxy Manager with HTTPS and the right headers

Guide nextcloud

6 steps 6 min read

Nextcloud and Nginx Proxy Manager are two of the containers I run on my Unraid server, and I know the pair well. The proxy half is easy. The part that bites is the small print: Nextcloud has to be told that it sits behind a proxy, or the admin Overview fills up with warnings. Here is the setup I would do, in the order I would do it, with every setting checked against the Nextcloud and Nginx Proxy Manager docs.

Time
6 min
Steps
6
Updated
19 Nov 2026

You will learn

  • The proxy host
  • The SSL tab
  • Advanced settings: uploads and headers
  • Tell Nextcloud about the proxy
  • The admin warnings
The Add Proxy Host dialog in Nginx Proxy Manager with scheme, forward host, port and the Websockets Support toggle

1. What you need

A working Nextcloud container, Nginx Proxy Manager (NPM), a domain that points at your public IP and ports 80 and 443 forwarded to NPM. Let’s Encrypt needs port 80 for its default HTTP check; a DNS challenge avoids that. From here on I use cloud.example.com as the domain and 192.168.1.x as the LAN range. Swap in your own.

Put NPM and Nextcloud on the same Docker network if you can, so NPM reaches Nextcloud by container name. If not, use the server’s LAN address and the port you mapped.

Step 1 of 6: The proxy host

In NPM go to Hosts, Proxy Hosts, Add Proxy Host. On the Details tab I set:

  • Domain Names: cloud.example.com
  • Scheme: http (Nextcloud’s own container speaks plain HTTP, NPM does the TLS)
  • Forward Hostname / IP and Forward Port: the Nextcloud container and its port
  • Block Common Exploits: on
  • Websockets Support: on. This is my habit, not a Nextcloud requirement; Nextcloud’s docs do not demand it, and I could not find a docs line that says otherwise.

I leave Cache Assets off for Nextcloud. That is my preference, so a changed file never gets served stale.

Step 2 of 6: The SSL tab

Open the SSL tab, pick “Request a new certificate” with Let’s Encrypt, and tick Force SSL and HTTP/2 Support. Force SSL sends every http:// request to https://, which is what you want.

Then the HSTS toggle. In NPM’s source, HSTS Enabled only does anything when Force SSL is on, and it sends Strict-Transport-Security: max-age=63072000; preload (two years). With HSTS Sub-domains it adds includeSubDomains. The caveat: browsers remember it. If you ever drop HTTPS on that domain, visitors are locked out until the timer ends. Nextcloud’s hardening page also warns that preload puts the domain on a hard-coded browser list that takes months to leave, and that you should drop includeSubDomains if a subdomain has no HTTPS. I turn HSTS on for a domain I know stays on HTTPS, and I leave the subdomain toggle off unless I mean it. Do not also add the header by hand in the advanced config, or it is sent twice.

The Certificates page in Nginx Proxy Manager with a Let's Encrypt certificate in use

Step 3 of 6: Advanced settings: uploads and headers

Open the gear tab of the same dialog (Nextcloud’s docs call the box “Custom Nginx Configuration”). Add this first, which Nextcloud’s reverse proxy page requires for NPM, otherwise iPhones and iPads can show “Connection Closed”:

proxy_hide_header Upgrade;

For big uploads, NPM’s own nginx already allows 2000 MB bodies and waits 90 seconds on the backend. Nextcloud’s clients upload in chunks of 100 MiB by default, so many setups never need more. If you hit a 413 or a timeout, I raise it for this host only:

client_max_body_size 10G;
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;

The numbers are mine; the directives are in the nginx.org docs. Nextcloud’s big file page also says a frontend nginx caps downloads at 1 GB through proxy_buffering and proxy_max_temp_file_size, and suggests turning buffering off. That is the one case where I would add proxy_buffering off;.

Step 4 of 6: Tell Nextcloud about the proxy

Nextcloud’s config sample says trusted_proxies lists the proxies whose forwarded headers it believes, and forwarded_for_headers names the header with the client IP (default HTTP_X_FORWARDED_FOR, which NPM sends). The docs warn that a wrong value lets clients spoof their IP. Run occ as the web user. In the official Docker image that is:

docker exec -it --user www-data Nextcloud php occ config:system:set trusted_domains 1 --value=cloud.example.com
docker exec -it --user www-data Nextcloud php occ config:system:set trusted_proxies 0 --value=192.168.1.0/24
docker exec -it --user www-data Nextcloud php occ config:system:set forwarded_for_headers 0 --value=HTTP_X_FORWARDED_FOR
docker exec -it --user www-data Nextcloud php occ config:system:set overwriteprotocol --value=https
docker exec -it --user www-data Nextcloud php occ config:system:set overwritehost --value=cloud.example.com
docker exec -it --user www-data Nextcloud php occ config:system:set overwrite.cli.url --value=https://cloud.example.com

On Unraid use your container’s name from the Docker tab, or open its Console and drop the docker exec part. The trusted proxy is whatever address NPM has when it reaches Nextcloud, so use the Docker network range or NPM’s address, not the browser’s. The docs call overwritehost unnecessary in most setups, so skip it if all works. The image also reads TRUSTED_PROXIES and OVERWRITEPROTOCOL variables, but TRUSTED_PROXIES only applies with APACHE_DISABLE_REWRITE_IP=1, so I prefer occ.

Step 5 of 6: The admin warnings

Under Administration settings, Overview, three warnings matter here.

Reverse proxy header configuration is incorrect. Almost always trusted_proxies is missing or does not match the proxy’s address. Fix it with the commands above.

/.well-known/caldav and /.well-known/carddav. Nextcloud’s docs say a proxy must do these redirects, and that if Nextcloud’s own web server is nginx behind another nginx, they belong only in the proxy. Put this in the same advanced box:

location /.well-known/carddav {
    return 301 $scheme://$host/remote.php/dav;
}
location /.well-known/caldav {
    return 301 $scheme://$host/remote.php/dav;
}

The docs also list a catch-all location ^~ /.well-known block for webfinger and nodeinfo.

Strict-Transport-Security. Nextcloud says to set the header in the web server; here that is the HSTS toggle in step 3. Older admin manuals say the check wants at least 15552000 seconds, and NPM sends 63072000.

Step 6 of 6: Check it

curl -I https://cloud.example.com
curl -I https://cloud.example.com/.well-known/caldav

The first should show strict-transport-security. The second should be a 301 to /remote.php/dav. Then reload the Overview page: the three warnings should be gone. As someone in Leiden, I like that the files stay on my own box at home and only the certificate comes from outside.

The Proxy Hosts list in Nginx Proxy Manager with a Let's Encrypt host marked Online

Further reading

Link