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 ( and the proxy is in a docker in an other device (host, docker, 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

My nextcloud.conf:

$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 => '',
    1 => 'my.domain',
    2 => '',
    3 => '',
  'trusted_proxies' =>
  array (
    0 => '',
    1 => '',
  'forwarded_for_headers' =>
  array (
    0 => 'X-Forwarded-For',
  'datadirectory' => '/var/www/html/nextcloud/data',
  'dbtype' => 'mysql',
  'version' => '',
  '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:


King regards

a curl 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


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.


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.