NginxProxyManager / nginx-proxy-manager

Docker container for managing Nginx proxy hosts with a simple, powerful interface
https://nginxproxymanager.com
MIT License
22.06k stars 2.54k forks source link

webdav can't rename files #2619

Open dyimo opened 1 year ago

dyimo commented 1 year ago
          can't rename files

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

dyimo commented 1 year ago

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;
hnoycy commented 1 year ago

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.

dyimo commented 1 year ago

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

Waldorf3 commented 1 year ago

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 ...
}
ichenhe commented 9 months ago

@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;
}
JayLiuX commented 6 months ago

@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?

ichenhe commented 6 months ago

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.

JayLiuX commented 6 months ago

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

ykrank commented 3 months ago

same problem