Nextcloud behind reverse proxy -> untrusted domain or encoding-error

Nextcloud version (20.0.1.1):
Operating system and version (Raspbain/Debian Buster):
Apache version ( 2.4.38):
Nginx version (1.14.2):
PHP version (eg, 7.3.19):

Hello, I am trying to set up my Nextcloud behind a reverse proxy (Nginx), both on the same server. I can access my Nextcloud via mydomain.com/nextcloud, but it reports untrusted domain. I tried using trusted_proxies, trusted_domains with multiple urls over 2 hours now. But i get untrusted domain or encoding-error. In my Nextcloud logs i can see, that it recognizes the website:

"remoteAddr":"xxx.xxx.xxx.xxx","user":"--","app":"core","method":"GET","url":"/nextcloud/cron.php","message":"Trusted domain error. \"xxx.xxx.xxx.xxx\" tried to access using \"mydomain.net\" as host."

My Nextcloud config (the parts that are important for proxies):

 'trusted_domains' =>
  array (
    0 => 'localhost',
    1 => '192.168.178.40',
    2 => 'mydomain.net/',
    3 => 'server.local',

  ),


  'trusted_proxies' => array( 0=>'192.168.178.40',),
  //'overwritehost' => 'mydomain.net/',         //If I set my website here, i get encoding error 
  'proxy' => '192.168.178.40:443',
  'overwriteprotocol' => 'https',
  'overwritewebroot'  => '/nextcloud',

My Nginx settings for the site looks like this:

server {
  listen 443 ssl;
  server_name mydomain.net;
  ssl_certificate      pathtocert/fullchain.pem;
  ssl_certificate_key  pathtocert/privkey.pem;

location ^~ /nextcloud/ {
   rewrite /nextcloud/(.*) /$1  break;
   proxy_pass http://192.168.178.40:4000;
   proxy_redirect http:// https://;

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_set_header X-Forwarded-Host $server_name;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection “upgrade”;
proxy_http_version 1.1;
add_header Front-End-Https on;
}

}

I asked in some Forum but i never got a working solution. I really hope you can help me, because I tried to many hours. :expressionless: It may be a small thing that i forgot to get it working.
Thank you! :smiley: