Nextcloud behind NPM: “Access via untrusted domain” & HTTP issues (TrueNAS SCALE)

Hello everyone,

I need help with my Nextcloud setup on TrueNAS SCALE. I’m stuck configuring the reverse proxy.

My setup:

OS: TrueNAS SCALE (current version)

App: Nextcloud (Official iX-Systems Chart)

Reverse proxy: Nginx Proxy Manager (NPM) as an app on the same TrueNAS

DNS/Domain: Cloudflare (proxy/orange cloud currently disabled, set to “DNS only”)

The problem: I have set up NPM and stored an SSL certificate for my domain. When I call up the domain, I can reach the server, but I encounter two problems:

Error message: “Access via an untrusted domain.”

Protocol error: The page is still displayed as “Not secure” (HTTP instead of HTTPS) in the browser, even though I am accessing it via the domain.

What I have already tried:

I wanted to customize config.php, but I am unable to do so due to permissions or the correct path in the TrueNAS shell (“Permission denied” or syntax error when copying to the shell). In addition, I was unable to enter the correct command because my SHELL keeps malfunctioning.

In NPM, the forward scheme is set to http because the proxy internally redirects to the IP 192.168.178.41.

I tried setting environment variables such as OVERWRITEPROTOCOL = https in the app configuration, but this sometimes resulted in a 400 Bad Request.

My questions:

What is the safest way to edit config.php in the official iX-Systems Nextcloud app to add trusted_domains and trusted_proxy?

Why does Nextcloud not recognize the HTTPS protocol from NPM correctly, even though the proxy is connected upstream?

I would be very grateful for step-by-step instructions for the shell (especially for obtaining write permissions for config.php)!

Thank you in advance!