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.


I’m having the same Problem. I’d love to solve that thing too. Heres something from my setup:
(Ubuntu 20.04.4 LTS - nginx/1.18.0 (also proxy/nextcloud) - php 8.1 - Nextcloud 24.0.3 )

And here are two HTTP Status Codes that I think have something to do with that problems (logged from reverse proxy via domain access):

 Request: PROPFIND /remote.php/dav/files/admin/ HTTP/2.0
 Status: 207

 Request: GET /core/preview?fileId=16897&x=250&y=250 HTTP/2.0
 Status: 404

Plus Nextcloud is giving me the error when accessing the settings from the domain (which is not appearing when accessing directly through the server ip):

Your web server is not yet properly set up to allow file synchronization, because the WebDAV interface seems to be broken

My Reverse Proxy should have the appropriate options for webdav passthrough (since copied from nextcloud nginx documentation), but it seems like their needs to be more?

though when I call “domain/.well-known/carddav” I get
“This is the WebDAV interface. It can only be accessed by WebDAV clients such as the Nextcloud desktop sync client.”
which seems to be right and working.

Not really sure if i can help you, but one question, what are your proxy settings concerning

    proxy_connect_timeout xxxx;
    proxy_send_timeout xxxx;
    proxy_read_timeout xxxx;
    send_timeout xxxx;

One working config is here maybe≥-24/

other explanations here

I found a Solution for my case, don’t know if it’s the same for you testcb00 but your error could be related to that as well. (chrissi55 solution seems valid for your error, so try that as well though). Solution for me, after a lot of testing, was simply updating to nginx/1.22.0. Thats the newest version available at this time but currently only through the nginx repo.

Steps to upgrade to nginx version 1.22.0:

add the repo in /etc/apt/sources.list like this:

#nginx Repo for newest version (swap "jammy" with your ubuntu version (f.e. focal) if neccessary):
deb [arch=amd64] jammy nginx
deb-src jammy nginx

make a test run with apt update - theres probably some gpg Error popping up (should end like this):
[…] because the public key is not available: NO_PUBKEY ABF5BD827BD9BF62

that hexadecimal number is the pub “key-id” (not sure how it’s described) which you can copy to add the key to your trusted keychain:

sudo apt-key add --keyserver --recv-keys ABF5BD827BD9BF62

If you want to make sure it’s the right “key-id”, check it on
→ search for “nginx signing key” and copy the last 16 characters of the pub key, thats the “key-id” - if it’s different than the above (your gpg Error Output), check the nginx documentation to see which is the right key or wether you got the right package)
(nginx Install documentation where it’s also kinda explained: Install | NGINX)

Instead of getting the pub “key-id” you can also (should work aswell, haven’t tried it myself):

curl -O && apt-key add ./nginx_signing.key

(nginx website with that command: Updating the GPG Key for NGINX Products - NGINX)

finally run:
apt update && apt install nginx
the newest version should be installed.

apt-key is deprecated and will be gone after Ubuntu 22.04. The new way would be something with gpg. Getting and “installing” the key is easy but I haven’t managed to make apt use it so far. So I went with the older but faster way (at the moment). If someone could explain a way without “apt-key add” I would be glad to hear that.

Thank you for your reply.

After some try on the setup, I go for hosting Nextcloud in Apache24 and use Nginx as Reverse Proxy. This setup solve all the problems but the speed will be weird.

I can get speed at 70 MB/s but then the speed will drop to 0MB/s at next second.
The average of uploading speed is around 35 MB/s
1s: 70 MB/s
2s: 0 MB/s
3s: 70MB/s
4s: 0MB/s

for me the error was triggered by the extension “collectives”

To resolve this issue it sounds like the chunk size either in the server or on the client side with the nextcloud app. Please also note if youre using cloudflare set your max chunk to under 100MB but I would set the auto chunk setting in the client and that made the transfer more smooth for me.