Nextcloud Nginx Proxy Manager 502 Bad Getway

Hi everyone,

I’m trying for a long time to get nextcloud working behind a reverse proxy. I have a 502 Bad Getway Error everytime

Quick infos:

My nextcloud is in a VM (192.168.0.22) and the proxy is in a docker in an other device (host 192.168.0.17, docker 172.18.0.2, deployed with portainer). I read many articles, tired many confs and it doesn’t work at all :-/ I still have a 502 error. All VM/hosts/etc are under debian 11. Here a my configs (let me know if you need any others).

Nextcloud apache.conf:

<VirtualHost *:80>
  DocumentRoot /var/www/html/nextcloud/
  ServerName  my.domain

  <Directory /var/www/html/nextcloud/>
    Require all granted
    AllowOverride All
    Options FollowSymLinks MultiViews

    <IfModule mod_dav.c>
      Dav off
    </IfModule>
  </Directory>
</VirtualHost>

My nextcloud.conf:

<?php
$CONFIG = array (
  'htaccess.RewriteBase' => '/',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'apps_paths' =>
  array (
    0 =>
    array (
      'path' => '/var/www/html/nextcloud/apps',
      'url' => '/apps',
      'writable' => false,
    ),
    1 =>
    array (
      'path' => '/var/www/html/nextcloud/custom_apps',
      'url' => '/custom_apps',
      'writable' => true,
    ),
  ),
  'instanceid' => 'ocbxfefef457445j31np6mjkjijfiej',
  'passwordsalt' => 'hF2m19lxeeJFknJuBfw6jhfRGHMMHajhjuhdzuhuhdz',
  'secret' => 'UCKRl9Cc5Uk6gvEkUu85lgiG5kIjeldXKCuJguQt5oE7J4684gehgdsqI',
  'trusted_domains' =>
  array (
    0 => '192.168.0.0/24',
    1 => 'my.domain',
    2 => '172.18.0.0/22',
    3 => '172.18.0.2:80',
  ),
  'trusted_proxies' =>
  array (
    0 => '192.168.0.0/24',
    1 => '172.18.0.0/16',
  ),
  'forwarded_for_headers' =>
  array (
    0 => 'X-Forwarded-For',
    1 => 'HTTP_X_FORWARDED_FOR',
  ),
  'datadirectory' => '/var/www/html/nextcloud/data',
  'dbtype' => 'mysql',
  'version' => '22.0.0.11',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'someuser',
  'dbpassword' => 'mypassword',
  'installed' => true,
  'overwriteprotocol' => 'https',
  'overwrite.cli.url' => 'https://my.domain',
  'overwritewebroot' => '/',
  'overwritehost' => 'my.domain',
);

My Nginx proxy manager config:

image

King regards

a curl http://192.168.0.22:80 from your docker host works? or from a container on this host? (i don’t know if you can get a shell inside the nginx proxy manager. you may try with portainer.)

this is not the server name of your apache webserver. this is the server name of your proxy. did you try without ServerName or with an additional ServerAlias 192.168.0.22

Hi,

I tried with/without ServerName and ServerAlias and both of them. Curl from localhost seems to work but not from docker host. I didn’t think about this… I disabled all firewall and still not reachable.

I also removed custom_apps array and set apps array writable.

@skollrc

hey , Did you solve the problem ? if so , how did you do that ? I have exactlly the same issue after almost a year …

I solved the issue, i have the same problem

You have http selected under Scheme and force SSL selected under SSL, change Scheme to https and port 443, unselect Websockets, HSTS and HTTP/2 also, see how that goes.