Can't access nextcloud from the outside - error 502

Hi Guys,

Background: UNRAID, MariaDB, NextCloud, Letsencrypt.

I have installed all the apps and they’re all working (I can access NC from the outside prior to installing Letsencrypt) but after installing Letsencrypt I’m unable to access from the outside, Cloudflare is giving error 502 (bad gateway). We have our own domain and I have an ‘A’ record pointing to our external IP which is mapped/natted into my NC server and I can also telnet to port 443 (my NC port). Letsencrypt was able to verify identity and cert was good. These are the NC config.php and NC subdomain proxy-conf. Any help is appreciated.

config.php (some info are change)
<?php
$CONFIG = array (
‘memcache.local’ => ‘\OC\Memcache\APCu’,
‘datadirectory’ => ‘/data’,
‘instanceid’ => ‘ocr0kaov7upo’,
‘passwordsalt’ => ‘yayayayayayayaya’,
‘secret’ => ‘yayayayayayayaya’,
‘trusted_domains’ =>
array (
0 => ‘1.1.1.1’,
1 => ‘nextcloud.domain.com’,
),
‘overwrite.cli.url’ => ‘https://nextcloud.domain.com’,
‘overwritehost’ => ‘nextcloud.domain.com’,
‘overwriteprotocol’ => ‘https’,
‘dbtype’ => ‘mysql’,
‘version’ => ‘13.0.5.2’,
‘dbname’ => ‘nextcloud’,
‘dbhost’ => ‘1.1.1.1:3306’,
‘dbport’ => ‘’,
‘dbtableprefix’ => ‘oc_’,
‘dbuser’ => ‘user’,
‘dbpassword’ => ‘password’,
‘installed’ => true,
‘mail_smtpmode’ => ‘smtp’,
‘mail_smtpauthtype’ => ‘LOGIN’,
‘mail_from_address’ => ‘nextcloud’,
‘mail_domain’ => ‘domain.com’,
‘mail_smtphost’ => ‘2.2.2.2’,
‘mail_smtpport’ => ‘25’,
);

letsencrypt nextcloud.subdomain.config

server {
    listen 443 ssl;

    server_name nextcloud.*;

    include /config/nginx/ssl.conf;

    client_max_body_size 0;

    location / {
        include /config/nginx/proxy.conf;
        resolver 127.0.0.11 valid=30s;
        set $upstream_nextcloud nextcloud;
        proxy_max_temp_file_size 2048m;
        proxy_pass https://$upstream_nextcloud:443;
    }
}

Thanks.

I’m able to log in now but come across another issue. We’re using cloudflare and if I only enable DNS I can log in to NC but the certificate is not recognized and if I enable DNS + http proxy, the certificate is installed but I’m getting Error 502 Bad gateway (I can telnet to port 443). Thanks