Cannot get WebDAV work under Nginx Reverse Proxy

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face: is for home/non-enterprise users. If you’re running a business, paid support can be accessed via where we can ensure your business keeps running smoothly.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:


Or for longer, use three backticks above and below the code snippet:


Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can :heart:

Nextcloud version (eg, 20.0.5): 24.0.3
Operating system and version (eg, Ubuntu 20.04): TrueNAS 12.0U8.1 Jail 12.2-RELEASE-p9
Apache or nginx version (eg, Apache 2.4.25): nginx/1.20.1 (Both Proxy / Nextcloud)
PHP version (eg, 7.4): 8.0

The issue you are facing:
I cannot connect to WebDAV using Reverse Proxy Domain, but I can connect to WebDAV using Server Address.

Both Proxy and Nextcloud are using https to Host

Is this the first time you’ve seen this error? (Y/N): Y

Steps to replicate it:

  1. Install Nextcloud
  2. Edit Config
  3. Connect to WebDAV via Proxy Domain

The output of your Nextcloud log in Admin > Logging:

No Log Related

The output of your config.php file in /usr/local/www/nextcloud (make sure you remove any identifiable information!):

$CONFIG = array (
  'instanceid' => '',
  'passwordsalt' => '',
  'secret' => '',
  'trusted_domains' =>
  array (
    1 => 'proxy_public_domain',
  'datadirectory' => '/mnt/data',
  'dbtype' => 'mysql',
  'version' => '',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost:/tmp/mysql.sock',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloud_admin',
  'dbpassword' => '',
  'installed' => true,
  'redis' =>
  array (
    'host' => '/var/run/redis/redis.sock',
    'port' => 0,
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'default_phone_region' => 'HK',
  'logfile' => '/usr/local/www/nextcloud/config/log/nextcloud.log',
  'loglevel' => 4,
  'enable_previews' => false,
  'overwrite.cli.url' => 'https://proxy.domain',
  'trusted_proxies' =>
  array (
    0 => 'proxy_local_domain',
  'overwritehost' => 'proxy_public_domain',
  'overwriteprotocol' => 'https',
  'updater.secret' => '',
  'maintenance' => false,
  'theme' => '',

The output of your Apache/nginx/system log in /var/log/____:

2022/08/06 17:28:25 [error] 66577#100453: *638 upstream prematurely closed connection while reading response header from upstream, client:, server:, request: "OPTIONS /remote.php/dav/files/USERNAME/ HTTP/1.1", upstream: "https://Nextcloud_Local_IP:443/remote.php/dav/files/USERNAME/", host: "proxy_public_domain"


Output errors in nextcloud.log in /var/www/ or as admin user in top right menu, filtering for errors. Use a pastebin service if necessary.