nginx-proxy-manager icon indicating copy to clipboard operation
nginx-proxy-manager copied to clipboard

webdav can't rename files

Open dyimo opened this issue 2 years ago • 12 comments

          can't rename files

Originally posted by @ensleep in https://github.com/NginxProxyManager/nginx-proxy-manager/issues/503#issuecomment-1257702561

dyimo avatar Feb 17 '23 07:02 dyimo

I tried using the code below but it doesn't work:

        set $fixed_destination $http_destination;
	if ( $http_destination ~* ^https(.*)$ ) {
	    set $fixed_destination http$1;
	}
	proxy_set_header Destination $fixed_destination;

dyimo avatar Feb 17 '23 07:02 dyimo

https://docutain.zendesk.com/hc/en-001/community/posts/5862028974994-Integration-Nginx-Proxy-Manager-Synology-WebDAV-Server You can try this, I successfully solved the problem by this method.

hnoycy avatar Feb 28 '23 06:02 hnoycy

https://docutain.zendesk.com/hc/en-001/community/posts/5862028974994-Integration-Nginx-Proxy-Manager-Synology-WebDAV-Server You can try this, I successfully solved the problem by this method.

Which webdav client are you using? win10

dyimo avatar May 04 '23 06:05 dyimo

Having the same problem here. https://www.dimoulis.net/posts/webdav-behind-reverse-proxy/ explains the problem is "MOVE and COPY methods use a Destination header that must match the scheme of Host e.g. https for https and not http. This isn’t true behind a reverse proxy.".

The page proceeds to offer a solution for standard Nginx configurations, but I can't get that to work in nginx-proxy-manager.

Hoping someone more clever can convert this so it works. I searched high and low for a solution to this, and though many are having the problem I don't find any conclusive solution.

upstream webdav {
    server 127.0.0.1:8080;
    keepalive 32;
}

server {
    server_name domain.tld;

    root /var/www/html;

    access_log /var/log/nginx/domain.tld;

    client_max_body_size 0;

    location / {
        auth_basic           "Restricted area";
        auth_basic_user_file /etc/nginx/.htpasswd;

    # https://mailman.nginx.org/pipermail/nginx/2007-January/000504.html - fix Destination: header
    # https://trac.nginx.org/nginx/ticket/348 - bug, workaround with named capture
    set $dest $http_destination;
    if ($http_destination ~ "^https://(?<myvar>(.+))") {
       set $dest http://$myvar;
    }
    proxy_set_header Destination       $dest;

    #rewrite /webdav/(.*) /$1 break;
    proxy_pass http://webdav;

    proxy_buffering off;

    # Keep-alive
    proxy_http_version                 1.1;
    proxy_set_header Connection        "";

    # Proxy headers
    proxy_set_header Host              $host;
    proxy_set_header X-Real-IP         $remote_addr;
    proxy_set_header X-Forwarded-For   $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-Host  $host;
    proxy_set_header X-Forwarded-Port  $server_port;

    # Proxy timeouts between successive read/write operations, not the whole request.
    proxy_connect_timeout              300s;
    proxy_send_timeout                 300s;
    proxy_read_timeout                 300s;

    listen [::]:443 ssl http2;
    listen 443 ssl http2;
    # ... SSL stuff ...
}

Waldorf3 avatar Aug 04 '23 18:08 Waldorf3

@Waldorf3 This config can not work in nginx-proxy-manager because all commands you write in Advanced tab will be placed inside the server{} block. But the upstream{} must be outside the server{} block.

So, here's a working version for NPM:

# no upstream{} block

client_max_body_size 0;

location / {
    # add your upstream directly
    proxy_pass http://192.168.1.1:5005;

    proxy_set_header Host              $host;
    proxy_set_header X-Real-IP         $remote_addr;
    proxy_set_header X-Forwarded-For   $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Host  $host;
    proxy_set_header X-Forwarded-Port  $server_port;

    proxy_connect_timeout              300s;
    proxy_send_timeout                 300s;
    proxy_read_timeout                 300s;

    set $dest $http_destination;
    if ($http_destination ~ "^https://(?<myvar>(.+))") {
       set $dest http://$myvar;
    }
    proxy_set_header Destination       $dest;
}

ichenhe avatar Dec 12 '23 23:12 ichenhe

@Waldorf3 This config can not work in nginx-proxy-manager because all commands you write in Advanced tab will be placed inside the server{} block. But the upstream{} must be outside the server{} block.

So, here's a working version for NPM:

# no upstream{} block

client_max_body_size 0;

location / {
    # add your upstream directly
    proxy_pass http://192.168.1.1:5005;

    proxy_set_header Host              $host;
    proxy_set_header X-Real-IP         $remote_addr;
    proxy_set_header X-Forwarded-For   $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Host  $host;
    proxy_set_header X-Forwarded-Port  $server_port;

    proxy_connect_timeout              300s;
    proxy_send_timeout                 300s;
    proxy_read_timeout                 300s;

    set $dest $http_destination;
    if ($http_destination ~ "^https://(?<myvar>(.+))") {
       set $dest http://$myvar;
    }
    proxy_set_header Destination       $dest;
}

I'm running in Docker, and I followed the configuration in the advanced settings as mentioned above, but it still doesn't work. Can you assist?

JayLiuX avatar Mar 19 '24 02:03 JayLiuX

I'm running in Docker, and I followed the configuration in the advanced settings as mentioned above, but it still doesn't work. Can you assist?

@JayLiuX 192.168.1.1 indicates local host, which is your docker container itself instead of the host. So, change it to your host's ip address.

Alternative, use host.docker.internal to represent the host. But in this case, please add the following to your compose.yml:

version: '3.8'
services:
  xxx:
    # add this ↓
    extra_hosts:
      - "host.docker.internal:host-gateway"

If you use command line directly, add --add-host=host.docker.internal:host-gateway to make sure this magic domian points to the host.

ichenhe avatar Mar 19 '24 09:03 ichenhe

I'm running in Docker, and I followed the configuration in the advanced settings as mentioned above, but it still doesn't work. Can you assist?

@JayLiuX 192.168.1.1 indicates local host, which is your docker container itself instead of the host. So, change it to your host's ip address.

Alternative, use host.docker.internal to represent the host. But in this case, please add the following to your compose.yml:

version: '3.8'
services:
  xxx:
    # add this ↓
    extra_hosts:
      - "host.docker.internal:host-gateway"

If you use command line directly, add --add-host=host.docker.internal:host-gateway to make sure this magic domian points to the host.

@ichenhe Here is my configuration. Among them, 192.168.31.215:5244 is the access address for my alist. Would you mind adding my contact information?I have sent my contact information to your email.

image

JayLiuX avatar Mar 19 '24 10:03 JayLiuX

same problem

ykrank avatar Jun 07 '24 12:06 ykrank

I have the same problem, and I've tried all the solutions above without any success.

I got my solution below.

RooobinYe avatar Oct 31 '24 06:10 RooobinYe

I have the same problem, and I've tried all the solutions without any success.

I solve it. Nas: ZSpace Z4

location / {
   proxy_pass http://192.168.110.104:5005/;   
   proxy_set_header Host $http_host;
   proxy_redirect  http:// https://;   
   proxy_set_header X-Forwarded-Host  $http_host;   
   proxy_set_header X-Forwarded-Port  $server_port;  
   proxy_set_header X-Forwarded-Proto $scheme;
   proxy_set_header X-Forwarded-Scheme $scheme;
   proxy_set_header X-Real-IP         $remote_addr;
   proxy_set_header X-Forwarded-For   $remote_addr;
   proxy_set_header Upgrade    $http_upgrade;
   proxy_set_header Connection $http_connection;
   proxy_http_version 1.1;
}

RooobinYe avatar Oct 31 '24 06:10 RooobinYe

Issue is now considered stale. If you want to keep it open, please comment :+1:

github-actions[bot] avatar Jun 13 '25 02:06 github-actions[bot]