Another Nextcloud in docker and nginx on different server

Support Issue

Nextcloud version : V23

Operating system and version : Ubuntu 20.04 server

System Setup:

1.Nginx on a seperate server
2. Nextcloud installed in docker on different server sitting behind proxy

The issue you are facing:

config.php:

<?php
$CONFIG = array (
  'htaccess.RewriteBase' => '/',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'apps_paths' =>
  array (
    0 =>
    array (
      'path' => '/var/www/html/apps',
      'url' => '/apps',
      'writable' => false,
    ),
    1 =>
    array (
      'path' => '/var/www/html/custom_apps',
      'url' => '/custom_apps',
      'writable' => true,
    ),
  ),
  'instanceid' => 'occt8ncufg12'',
  'passwordsalt' => 'blahblah
  'secret' => '3blahblah',
  'trusted_domains' =>
  array (
    0 => 'nextcloud.blahablah.xyz',
    1 => '192.168.1.143:8900',
    2 => 'nextcloud',
  ),
  'trusted_proxies' =>
  array (
    0 => '192.168.1.139',
    1 => 'nginx.blahblah.xyz'
  ),
  'datadirectory' => '/var/www/html/data',
  'dbtype' => 'mysql',
  'version' => '23.0.0.10',
  'overwrite.cli.url' => 'http://nextcloud.blahblah.xyz',
  'overwriteprotocol' => 'http',
  'dbname' => 'nextcloud',
  'dbhost' => 'nextclouddb',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloud',
  'dbpassword' => 'secret',
  'installed' => true,
  'maintenance' => false,
);



Nginx config:

server {
  #listen 443 ssl http2;
   #listen [::]:443 ssl http2;

    server_name nextcloud.blahblah.xyz;

    charset     utf-8;
    access_log /var/log/nginx/nextcloud.access;
    error_log /var/log/nginx/nextcloud.error;

    resolver 192.168.1.254; 
    
    ssl_stapling on;
    ssl_stapling_verify on;

    add_header Strict-Transport-Security "max-age=63072000" always;
   
    


    location / {
       
        proxy_pass http://192.168.1.143:8900;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-Proto $scheme;
        client_max_body_size 1G;
}

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

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


    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/nextcloud.blahblah.xyz/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/nextcloud.blahblah.xyz/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}
server {
    if ($host = nextcloud.blahblah.xyz) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    listen 80;

    server_name nextcloud.blahblah.xyz;
    return 404; # managed by Certbot


}

Hope someone can help or is having the same issue and i know there is 100 nginx topics and i have had a look through all. The nginx conf is working correctly if i go to nextcloud.blahblah.xyz; it opens up with https and i can login and do whatever. But if i try to add to IOS app or Nextcloud WIndows Client it get pass login and then an error

 The polling URL does not start with the HTTPS despite the login URL started with HTTPS

Now if i change :

'overwrite.cli.url' => 'http://nextcloud.blahblah.xyz',
  'overwriteprotocol' => 'http',

to HTTPS the error doesnt appear but the local ip address is in the weblink and not using https://nextcloud.blahblah.xyz

Not sure how to fix. Is there a way to redirect to http for that part?