Nginx proxy docker to docker (untrusted domain)

Hello!
Now nexctloud works completely in docker on one server. I’m trying to move the nginx proxy to a separate server, also in docker. Current setup:
10.77.250.20 - new nginx proxy
10.77.250.5 - nextclod server (nginx + php + db)
testcloud.domain.ru - dns name

Nginx proxy (10.77.250.20) config :

upstream nextcloudservers {
server 10.77.250.5:443;
}

server {
listen 443 ssl default_server http2;
server_name testcloud.domain.ru;
ssl_certificate /etc/nginx/ssl/domain_ru_2021.pem;
ssl_certificate_key /etc/nginx/ssl/domain_ru_2021.key;

location / {
proxy_pass https://nextcloudservers/;
proxy_set_header Connection "Keep-Alive";
proxy_set_header Proxy-Connection "Keep-Alive";

proxy_set_header X-Forwarded-Host testcloud.domain.ru;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 }
}

Nginx nextcloud (10.77.250.5):

 upstream php-handler {
 #    server 10.77.250.5:9000;    ## tried this too, but nothing changed
     server 172.17.0.1:9000;
 }
 
 server {
     listen 80;
     listen [::]:80;
     server_name testcloud.domain.ru;
 
     return 301 https://$server_name$request_uri;
 }
 
 server {
     proxy_connect_timeout   90s;
     proxy_send_timeout  120s;
     proxy_read_timeout  120s;
 
     listen 443      ssl http2;
     listen [::]:443 ssl http2;
     server_name testcloud.domain.ru;
 
    ssl_certificate     /etc/nginx/ssl/domain_ru_2021.pem;
    ssl_certificate_key /etc/nginx/ssl/domain_ru_2021.key;
 
 ### next, the standard config for php, it does not seem to affect the problem###

Config.php (10.77.250.5):

  'trusted_proxies' =>
  array (
    0 => '10.77.250.20',
    1 => '172.17.0.1',
  ),
  'trusted_domains' => 
  array (
    0 => 'testcloud.domain.ru',
    1 => '10.77.250.20', # proxy
    2 => '10.77.250.5',   # nexctloud
    3 => '172.17.0.1',
  ),

When trying to open testcloud.domain.ru I get the error “Access via an untrusted domain”. If i change the proxy proxy_pass in the nginx config to https://10.77.250.5:443;, then the site opens, but there is respectively the address 10.77.250.5, and not testcloud.domain.ru.

Please tell me what I’m doing wrong? How can I check which domain is being logged in?

It was a typo in trusted domain :sob:… Anyway, is there any way to check which domain is being logged in?