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

Nextcloud version (
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, 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":"","user":"--","app":"core","method":"GET","url":"/nextcloud/cron.php","message":"Trusted domain error. \"\" tried to access using \"\" as host."

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

 'trusted_domains' =>
  array (
    0 => 'localhost',
    1 => '',
    2 => '',
    3 => 'server.local',


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

My Nginx settings for the site looks like this:

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

location ^~ /nextcloud/ {
   rewrite /nextcloud/(.*) /$1  break;
   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: