Dostęp do plików Nextcloud za pomocą WebDAV

Nextcloud fully supports the WebDAV protocol, and you can connect and synchronize with Nextcloud Files over WebDAV. In this chapter, you will learn how to connect Linux, macOS, Windows, and mobile devices to your Nextcloud server.

WebDAV stands for Distributed Authoring and Versioning. It is an HTTP extension that makes it easy to create, read, and edit files hosted on remote Web servers. With a WebDAV, client you can access your Nextcloud Files (including shares) on Linux, macOS and Windows in a similar way as any remote network share, and stay synchronized.

Before we get into configuring WebDAV, let’s take a quick look at the recommended way of connecting client devices to Nextcloud.

Official Nextcloud desktop and mobile clients

The recommended way to synchronize a computer with a Nextcloud server is by using the official Nextcloud sync clients. You can configure the client to save files in any local directory and you can choose which directories on the Nextcloud server to sync with. The client displays the current connection status and logs all activity, so you always know which remote files have been downloaded to your PC and you can verify that files created and updated on your local PC are properly synchronized with the server.

The recommended way to synchronize Android and Apple iOS devices is by using the official Nextcloud mobile apps.

To connect the official Nextcloud apps to a Nextcloud server use the same URL you use to access Nextcloud from your web browser - e.g.:

https://cloud.example.com

https://cloud.example.com/nextcloud (if Nextcloud is installed in a subdirectory)

Third-party WebDAV clients

If you prefer, you may also connect your computer to your Nextcloud server by using any third-party client that supports the WebDAV protocol (including what may be built into your operating system).

You can also use third-party WebDAV capable apps to connect your mobile device to Nextcloud.

When using third-party clients, keep in mind that they may not be optimized for use with Nextcloud or implement capabilities you consider important to your use case.

Mobile clients that Nextcloud community members have reported using include:

The URL to use when configuring third-party apps to connect to Nextcloud is a bit lengthier than the one for official clients:

https://cloud.example.com/remote.php/dav/files/USERNAME/

https://cloud.example.com/nextcloud/remote.php/dav/files/USERNAME/ (if Nextcloud is installed in a subdirectory)

Informacja

When using a third-party WebDAV client (including your operating system’s built-in client), you should use an application password for login rather than your regular password. In addition improved security, this increases performance significantly <https://github.com/nextcloud/server/issues/32729#issuecomment-1556667151>_. To configure an application password, log into the Nextcloud Web interface, click on the avatar in the top right and choose Personal settings. Then choose Security in the left sidebar and scroll to the very bottom. There you can create an app password (which can also be revoked in the future without changing your main user password).

Informacja

In the following examples, you should replace example.com/nextcloud with the URL of your Nextcloud server (omit the directory part if the installation is in the root of your domain), and USERNAME with the username of the connecting user.

Zobacz adres URL WebDav (na dole po lewej w ustawieniach) w swoim Nextcloud.

Dostęp do plików w systemie Linux

Dostęp do plików w systemach operacyjnych Linux można uzyskać, korzystając z następujących metod.

Menedżer plików Nautilus

Kiedy skonfigurujesz swoje konto Nextcloud w Centrum sterowania GNOME, Twoje pliki zostaną automatycznie zamontowane przez Nautilusa jako udostępnienie WebDAV, chyba że odznaczysz dostęp do plików.

Możesz także ręcznie zamontować pliki Nextcloud. Użyj protokołu davs://, aby połączyć menedżera plików Nautilus z udostępnieniem Nextcloud:

davs://example.com/nextcloud/remote.php/dav/files/USERNAME/

Informacja

Jeśli połączenie z serwerem nie jest zabezpieczone przez HTTPS, użyj dav:// zamiast davs://:

Screenshot of configuring Nautilus file manager to use WebDAV

Informacja

The same method works for other file managers that use GVFS, such as MATE’s Caja and Cinnamon’s Nemo.

Dostęp do plików za pomocą menedżera plików KDE i Dolphin

Aby uzyskać dostęp do plików Nextcloud za pomocą menedżera plików Dolphin w KDE, użyj protokołu webdav://:

webdav://example.com/nextcloud/remote.php/dav/files/USERNAME/
Screenshot of configuring Dolphin file manager to use WebDAV

Możesz utworzyć stałe łącze do swojego serwera Nextcloud:

  1. Open Dolphin and click „Network” in the left-hand „Places” column.

  2. Kliknij ikonę oznaczoną Dodaj folder sieciowy. Wynikowe okno dialogowe powinno zostać wyświetlone już z wybranym protokołem WebDAV.

  3. Jeśli WebDAV nie jest zaznaczone, wybierz go.

  4. Kliknij Następny.

  5. Wprowadź następujące ustawienia:

    • Name: the name you want to see in the Places bookmark, for example, Nextcloud.

    • User: the Nextcloud username you used to log in, for example, admin.

    • Server: the Nextcloud domain name, for example, example.com (without http:// before or directories afterwards).

    • Folder - wprowadź ścieżkę nextcloud/remote.php/dav/files/USERNAME/.

  6. (Opcjonalnie) Zaznacz pole wyboru „Utwórz ikonę”, aby w kolumnie Miejsca pojawiła się zakładka.

  7. (Opcjonalnie) Podaj specjalne ustawienia lub certyfikat SSL w polu „Port i Szyfrowanie”.

Tworzenie montowań WebDAV w wierszu poleceń systemu Linux

Punkty montowania WebDAV można tworzyć z wiersza poleceń systemu Linux. Jest to przydatne, jeśli wolisz uzyskać dostęp do Nextcloud w taki sam sposób, jak do każdego innego zdalnego montowania systemu plików. Poniższy przykład pokazuje, jak utworzyć osobiste montowanie i montować go automatycznie za każdym razem, gdy logujesz się do komputera z systemem Linux.

  1. Zainstaluj sterownik systemu plików davfs2 WebDAV, który umożliwia montowanie udostępnień WebDAV tak jak każdy inny zdalny system plików. Użyj tego polecenia, aby zainstalować go w systemie Debian/Ubuntu:

    apt-get install davfs2
    
  2. Użyj tego polecenia, aby zainstalować go w CentOS, Fedorze i openSUSE:

    yum install davfs2
    
  3. Dodaj się do grupy davfs2`:

    usermod -aG davfs2 <username>
    
  4. Then create a nextcloud directory in your home directory for the mount point, and .davfs2/ for your personal configuration file:

    mkdir ~/nextcloud
    mkdir ~/.davfs2
    
  5. Skopiuj /etc/davfs2/secrets do ~/.davfs2:

    cp  /etc/davfs2/secrets ~/.davfs2/secrets
    
  6. Ustaw siebie jako właściciela i nadaj uprawnienia tylko do odczytu i zapisu:

    chown <linux_username>:<linux_username> ~/.davfs2/secrets
    chmod 600 ~/.davfs2/secrets
    
  7. Dodaj swoje dane logowania do Nextcloud na końcu pliku secrets, używając adresu URL serwera Nextcloud oraz nazwy użytkownika i hasła Nextcloud:

    https://example.com/nextcloud/remote.php/dav/files/USERNAME/ <username> <password>
    or
    $PathToMountPoint $USERNAME $PASSWORD
    for example
    /home/user/nextcloud john 1234
    
  8. Dodaj informacje o montowaniu do /etc/fstab:

    https://example.com/nextcloud/remote.php/dav/files/USERNAME/ /home/<linux_username>/nextcloud davfs user,rw,auto 0 0
    
  9. Następnie sprawdź, czy montuje i uwierzytelnia się, uruchamiając następujące polecenie. Jeśli skonfigurujesz to poprawnie, nie będziesz potrzebować uprawnień roota:

    mount ~/nextcloud
    
  10. Powinieneś także móc go odmontować:

    umount ~/nextcloud
    

Teraz za każdym razem, gdy logujesz się do systemu Linux, udostępnianie Nextcloud powinno automatycznie montować się za pośrednictwem WebDAV w katalogu ~/nextcloud. Jeśli wolisz zamontować go ręcznie, zmień auto na noauto` w ``/etc/fstab.

Znane problemy

Zagadnienie

Zawartość chwilowo niedostępna

Rozwiązanie

Jeśli napotkasz problemy podczas tworzenia pliku w katalogu, edytuj /etc/davfs2/davfs2.conf i dodaj:

use_locks 0

Zagadnienie

Ostrzeżenia dotyczące certyfikatu

Rozwiązanie

Jeśli używasz certyfikatu z podpisem własnym, pojawi się ostrzeżenie. Aby to zmienić, musisz skonfigurować davfs2, aby rozpoznawał Twój certyfikat. Skopiuj plik mycertificate.pem do /etc/davfs2/certs/. Następnie edytuj /etc/davfs2/davfs2.conf i odkomentuj wiersz servercert. Teraz dodaj ścieżkę swojego certyfikatu, jak w tym przykładzie:

servercert /etc/davfs2/certs/mycertificate.pem

Dostęp do plików za pomocą macOS

Informacja

The macOS Finder suffers from a series of implementation problems and should only be used if the Nextcloud server runs on Apache and mod_php, or Nginx 1.3.8+. Alternative macOS-compatible clients capable of accessing WebDAV shares include open source apps like Cyberduck (see instructions here) and Filezilla. Commercial clients include Mountain Duck, Forklift, Transmit, and Commander One.

Aby uzyskać dostęp do plików za pomocą Findera macOS:

  1. From the Finder’s top menu bar, choose Go > Connect to Server…:

    Screenshot of entering your Nextcloud server address on macOS
  2. When the Connect to Server… window opens, enter your Nextcloud server’s WebDAV address in the Server Address: field, i.e.:

    https://cloud.YOURDOMAIN.com/remote.php/dav/files/USERNAME/
    
    Screenshot: Enter Nextcloud server address in "Connect to Server…" dialog box
  3. Kliknij Połącz. Twój serwer WebDAV powinien pojawić się na pulpicie jako udostępniony dysk.

Dostęp do plików za pomocą systemu Microsoft Windows

If you use the native Windows implementation of WebDAV, you can map Nextcloud to a new drive using Windows Explorer. Mapping to a drive enables you to browse files stored on a Nextcloud server the way you would browse files stored in a mapped network drive.

Korzystanie z tej funkcji wymaga połączenia sieciowego. Jeśli chcesz przechowywać pliki w trybie offline, użyj programu Desktop Client, aby zsynchronizować wszystkie pliki na Nextcloud z jednym lub kilkoma katalogami na lokalnym dysku twardym.

Informacja

Windows 10 now defaults to allow Basic Authentication if HTTPS is enabled before mapping your drive.

On older versions of Windows, you must permit the use of Basic Authentication in the Windows Registry:

  • launch regedit and navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WebClient\Parameters.

  • Create or edit the BasicAuthLevel (Windows Vista, 7 and 8), or UseBasicAuth (Windows XP and Windows Server 2003), DWORD value and set its value data to 1 for SSL connections. A value of 0 means that Basic Authentication is disabled, and a value of 2 allows both SSL and non-SSL connections (not recommended).

  • Then exit Registry Editor, and restart the computer.

Mapowanie dysków za pomocą wiersza poleceń

Poniższy przykład pokazuje, jak zmapować dysk za pomocą wiersza polecenia. Aby zmapować dysk:

  1. Otwórz wiersz polecenia w systemie Windows.

  2. Wprowadź następujący wiersz w wierszu polecenia, aby zamapować na dysk Z komputera:

    net use Z: https://<drive_path>/remote.php/dav/files/USERNAME/ /user:youruser yourpassword
    

    with <drive_path> as the URL to your Nextcloud server. For example:

    net use Z: https://example.com/nextcloud/remote.php/dav/files/USERNAME/ /user:youruser yourpassword
    

    Komputer mapuje pliki z Twojego konta Nextcloud na dysk z literą Z.

Informacja

If you get the following error System error 67 has occurred. The network name cannot be found., open the Services app and make sure that the WebClient service is running and started automatically at startup.

Informacja

Though not recommended, you can also mount the Nextcloud server using HTTP, leaving the connection unencrypted.

If you plan to use HTTP connections on devices while in a public place, we strongly recommend using a VPN tunnel to provide the necessary security.

Alternatywna składnia polecenia to:

net use Z: \\example.com@ssl\nextcloud\remote.php\dav /user:youruser
yourpassword

Mapowanie dysków za pomocą Eksploratora Windows

To map a drive using Microsoft Windows Explorer:

  1. Otwórz Eksploratora Windows na komputerze z systemem MS Windows.

  2. Kliknij prawym przyciskiem myszy na Komputer i wybierz Mapuj dysk sieciowy… z menu rozwijanego.

  3. Wybierz lokalny dysk sieciowy, na który chcesz zmapować Nextcloud.

  4. Podaj adres swojej instancji Nextcloud, a następnie /remote.php/dav/files/USERNAME/.

    Na przykład:

    https://example.com/nextcloud/remote.php/dav/files/USERNAME/
    

    Informacja

    For SSL-protected servers, check Reconnect at sign-in to ensure that the mapping is persistent upon subsequent reboots. If you want to connect to the Nextcloud server as a different user, check Connect using different credentials.

    Screenshot of mapping WebDAV on Windows Explorer
  1. Kliknij przycisk Zakończ.

Eksplorator Windows mapuje dysk sieciowy, udostępniając dostępny Nextcloud.

Dostęp do plików za pomocą Cyberduck

Cyberduck is an open source FTP, SFTP, WebDAV, OpenStack Swift, and Amazon S3 browser designed for file transfers on macOS and Windows.

Informacja

W tym przykładzie zastosowano Cyberduck w wersji 4.2.1.

Aby skorzystać z Cyberduck:

  1. Specify a server without any leading protocol information.

    For example: example.com

  2. Specify the appropriate port.

    The port you choose depends on whether or not your Nextcloud server supports SSL. Cyberduck requires that you select a different connection type if you plan to use SSL.

    For example:
    • 80 for unencrypted WebDAV

    • 443 for secure WebDAV (HTTPS/SSL)

  3. Use the «More Options» drop-down menu to add the rest of your WebDAV URL into the «Path» field.

    For example: remote.php/dav/files/USERNAME/

Teraz Cyberduck umożliwia dostęp do plików na serwerze Nextcloud.

Dostęp do udostępnień publicznych przez WebDAV

Nextcloud provides the possibility to access public shares anonymously over WebDAV.

Aby uzyskać dostęp do udostępnień publicznych, otwórz:

https://example.com/nextcloud/public.php/webdav

in a WebDAV client, use the share token as username and the (optional) share password as the password. For example, with a share link https://example.com/s/kFy9Lek5sm928xP, kFy9Lek5sm928xP will be the username.

Informacja

SettingsAdministrationSharingAllow users on this server to send shares to other servers. This option also allows WebDAV access to public shares and needs to be enabled to make this feature work, except if cURL is being used (see below).

Znane problemy

Zagadnienie

System Windows nie łączy się przy użyciu protokołu HTTPS.

Rozwiązanie 1

Klient Windows WebDAV może nie obsługiwać nazwy serwera (SNI) w połączeniach szyfrowanych. Jeśli napotkasz błąd podczas montowania zaszyfrowanej SSL instancji Nextcloud, skontaktuj się ze swoim dostawcą w sprawie przypisania dedykowanego adresu IP dla serwera opartego na SSL.

Rozwiązanie 2

Klient Windows WebDAV może nie obsługiwać połączeń TLSv1.1 i TLSv1.2. Jeśli ograniczyłeś konfigurację serwera do zapewniania tylko TLSv1.1 i nowszych, połączenie z serwerem może się nie powieść. Więcej informacji można znaleźć w dokumentacji WinHTTP.

Zagadnienie

Pojawia się następujący komunikat o błędzie: Błąd 0x800700DF: Rozmiar pliku przekracza dozwolony limit i nie można go zapisać.

Rozwiązanie

System Windows ogranicza maksymalny rozmiar pliku przesyłanego z lub do udostępnienia WebDAV. Możesz zwiększyć wartość FileSizeLimitInBytes w HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WebClient\Parameters, klikając Modyfikuj.

Aby zwiększyć limit do maksymalnej wartości 4GB, wybierz opcję Decimal, wprowadź wartość 4294967295 i uruchom ponownie system Windows lub uruchom ponownie usługę WebClient.

Zagadnienie

Adding a WebDAV drive on Windows via the above described steps does not display the correct size of in Nextcloud available space and instead shows the size of the C: drive with its available space.

Answer

Unfortunately is this a limitation of WebDAV itself, because it does not provide a way for the client to get the available free space from the server. Windows automatically falls back to show the size of the C: drive with its available space instead. So unfortunately there is no real solution to this problem.

Zagadnienie

Uzyskiwanie dostępu do plików z Microsoft Office przez WebDAV kończy się niepowodzeniem.

Rozwiązanie

Znane problemy i sposoby ich rozwiązywania opisano w artykule KB2123563.

Zagadnienie

Cannot map Nextcloud as a WebDAV drive in Windows using a self-signed certificate.

Rozwiązanie

  1. Access to your Nextcloud instance via your favorite Web browser.

  2. Klikaj, aż pojawi się błąd certyfikatu w wierszu stanu przeglądarki.

  3. View the certificate, then from the Details tab, select «Copy to File».

  4. Save the file to your desktop with an arbitrary name, for example myNextcloud.pem.

  5. Go to Start menu > Run, type MMC, and click «OK» to open Microsoft Management Console.

  6. Go to File > Add/Remove Snap-In.

  7. Select Certificates, Click «Add», choose «My User Account», then «Finish», and finally «OK».

  8. Przejdź do sekcji Trust Root Certification Authorities, Certificates.

  9. Right-Click Certificate, Select All Tasks, and Import.

  10. Select the saved certificate from the Desktop.

  11. Select Place all Certificates in the following Store, and click Browse.

  12. Check the Box that says Show Physical Stores, expand out Trusted Root Certification Authorities, select Local Computer there, click «OK», and Complete the Import.

  13. Check the list to make sure the certificate shows up. You will probably need to Refresh before you see it.

  14. Exit MMC.

For Firefox users:

  1. Launch your browser, go to Application menu > History > Clear recent history…

  2. Select «Everything» in the «Time range to clear» dropdown menu

  3. Select the «Active Logins» check box

  4. Click the «Clear now» button

  5. Close the browser, then re-open and test.

For Chrome-based browsers (Chrome, Chromium, Microsoft Edge) users:

  1. Open Windows Control Panel, navigate down to Internet Options

  2. In the Content tab, click the Clear SSL State button.

  3. Close the browser, then re-open and test.

Dostęp do plików przy użyciu cURL

Ponieważ WebDAV jest rozszerzeniem HTTP, cURL, może być używany do skryptowania operacji na plikach.

Informacja

SettingsAdministrationSharingAllow users on this server to send shares to other servers. If this option is disabled, the option --header "X-Requested-With: XMLHttpRequest" needs to be passed to cURL.

Aby utworzyć folder z bieżącą datą jako nazwa:

$ curl -u user:pass -X MKCOL "https://example.com/nextcloud/remote.php/dav/files/USERNAME/$(date '+%d-%b-%Y')"

Aby przesłać plik error.log do tego katalogu:

$ curl -u user:pass -T error.log "https://example.com/nextcloud/remote.php/dav/files/USERNAME/$(date '+%d-%b-%Y')/error.log"

Aby przenieść plik:

$ curl -u user:pass -X MOVE --header 'Destination: https://example.com/nextcloud/remote.php/dav/files/USERNAME/target.jpg' https://example.com/nextcloud/remote.php/dav/files/USERNAME/source.jpg

Aby uzyskać właściwości plików w folderze głównym:

    $ curl -X PROPFIND -H "Depth: 1" -u user:pass https://example.com/nextcloud/remote.php/dav/files/USERNAME/ | xml_pp
    <?xml version="1.0" encoding="utf-8"?>
<d:multistatus xmlns:d="DAV:" xmlns:oc="http://nextcloud.org/ns" xmlns:s="http://sabredav.org/ns">
  <d:response>
    <d:href>/nextcloud/remote.php/dav/files/USERNAME/</d:href>
    <d:propstat>
      <d:prop>
        <d:getlastmodified>Tue, 13 Oct 2015 17:07:45 GMT</d:getlastmodified>
        <d:resourcetype>
          <d:collection/>
        </d:resourcetype>
        <d:quota-used-bytes>163</d:quota-used-bytes>
        <d:quota-available-bytes>11802275840</d:quota-available-bytes>
        <d:getetag>"561d3a6139d05"</d:getetag>
      </d:prop>
      <d:status>HTTP/1.1 200 OK</d:status>
    </d:propstat>
  </d:response>
  <d:response>
    <d:href>/nextcloud/remote.php/dav/files/USERNAME/welcome.txt</d:href>
    <d:propstat>
      <d:prop>
        <d:getlastmodified>Tue, 13 Oct 2015 17:07:35 GMT</d:getlastmodified>
        <d:getcontentlength>163</d:getcontentlength>
        <d:resourcetype/>
        <d:getetag>"47465fae667b2d0fee154f5e17d1f0f1"</d:getetag>
        <d:getcontenttype>text/plain</d:getcontenttype>
      </d:prop>
      <d:status>HTTP/1.1 200 OK</d:status>
    </d:propstat>
  </d:response>
</d:multistatus>

Accessing files using WinSCP

WinSCP is an open source free SFTP, FTP, WebDAV, S3, and SCP client for Windows. Its main function is file transfer between a local and a remote computer. Beyond this, WinSCP offers scripting and basic file management functionality.

You can download the portable version of WinSCP and run it on Linux through Wine.

To run WinSCP on Linux, download wine through your distribution’s package manager, then run it with the command: wine WinSCP.exe.

To connect to Nextcloud:

  • Start WinSCP

  • Press «Session» in the menu

  • Press the «New Session» menu option

  • Set the «File protocol» dropdown to WebDAV

  • Set the «Encryption» dropdown to TLS/SSL Implicit encryption

  • Fill in the hostname field: example.com

  • Fill in the username field: NEXTCLOUDUSERNAME

  • Fill in the password field: NEXTCLOUDPASSWORD

  • Press the «Advanced…» button

  • Navigate to «Environment», «Directories» on the left side

  • Fill in the «Remote directory» field with the following: /nextcloud/remote.php/dav/files/NEXTCLOUDUSERNAME/

  • Press the «OK» button

  • Press the «Save» button

  • Select the desired options and press the «OK» button

  • Press the «Login» button to connect to Nextcloud

Informacja

It is recommended to use an app password for the password if you use TOTP as WinSCP does not understand TOTP with Nextcloud at the time of writing (2022-11-07).