Accedere ai file di Nextcloud usando 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 via WebDAV. Before we get into configuring WebDAV, let’s take a quick look at the recommended way of connecting client devices to your Nextcloud servers.

Nota

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.

Vedi l’URL di webdav (in basso a sinistra nelle impostazioni) nel tuo Nextcloud.

Nota

In the following examples, you must use an application password for login, which you can generate in your security settings.

Client Nextcloud Desktop e mobile

Il modo consigliato per sincronizzare un PC desktop con un server Nextcloud è utilizzando il client di sincronizzazione di Nextcloud/ownCloud. Puoi configurare il client in modo da salvare i file in qualunque cartella locale e puoi scegliere quali cartelle presenti sul server Nextcloud sincronizzare. Il client mostra lo stato di connessione attuale e registra tutte le attività, così puoi sempre sapere quale file remoto è stato scaricato sul tuo PC e puoi verificare che i file creati e aggiornati sul tuo PC locale siano propriamente sincronizzati con il server.

Il modo consigliato per sincronizzare il server Nextcloud con dispositivi Android e Apple iOS è tramite l’utilizzo di applicazioni per dispositivi mobili.

Per connettere la tua applicazione per dispositivi mobili a un server Nextcloud usa solo l’URL di base e la cartella:

example.com/nextcloud

In aggiunta alle applicazioni per dispositivi mobili fornite da Nextcloud o ownCloud, puoi usare altre applicazioni per connetterti a Nextcloud dal tuo dispositivo mobile usando WebDAV. WebDAV Navigator è una buona applicazione (proprietaria) per dispositivi Android e iPhones. L’URL da usare su questi è:

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

Configurazione WebDAV

If you prefer, you may also connect your desktop PC to your Nextcloud server by using the WebDAV protocol rather than using a special client application. Web Distributed Authoring and Versioning (WebDAV) is a Hypertext Transfer Protocol (HTTP) extension that makes it easy to create, read, and edit files on Web servers. With WebDAV, you can access your Nextcloud shares on Linux, macOS and Windows in the same way as any remote network share, and stay synchronized.

Accedere ai file usando Linux

Puoi accedere ai file nel sistema operativo Linux utilizzando i seguenti metodi.

Gestore file Nautilus

When you configure your Nextcloud account in the GNOME Control Center, your files will automatically be mounted by Nautilus as a WebDAV share, unless you deselect file access.

Puoi anche montare i tuoi file Nextcloud manualmente. Usa il protocollo davs:// per connettere il gestore file Nautilus alle tue risorse condivise Nextcloud:

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

Nota

Se la tua connessione al server non è protetta con HTTPS, usa dav:// invece che davs://:

Screenshot of configuring Nautilus file manager to use WebDAV

Nota

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

Accedere ai file con KDE e il gestore file Dolphin

Per accedere ai tuoi file Nextcloud usando il gestore file Dolphin in KDE, usa il protocollo webdav://:

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

Puoi creare un collegamento permanente al tuo server Nextcloud:

  1. Open Dolphin and click «Network» in the left-hand «Places» column.

  2. Fai clic sull’icona etichettata Aggiungi una cartella di rete. La seguente finestra di dialogo dovrebbe apparire con WebDAV già selezionato.

  3. Se WebDAV non è selezionato, selezionalo.

  4. Fai clic su Avanti.

  5. Inserisci le seguenti impostazioni:

    • 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).

    • Cartella – Inserisci il percorso nextcloud/remote.php/dav/files/NOMEUTENTE/.

  6. (Opzionale) Seleziona la casella di selezione «Crea icona» per visualizzare un segnalibro nella colonna Risorse.

  7. (Opzionale) Fornisci qualunque impostazione speciale o un certificato SSL nella casella «Porta e cifrato».

Creare montaggi WebDAV sulla riga di comando Linux.

Puoi creare il montaggio di WebDAV dalla riga di comando di Linux. Ciò è utile se preferisci accedere a Nextcloud come qualunque altro filesystem remoto montato. Il seguente esempio mostra come creare un montaggio personale e averlo montato automaticamente ogni qual volta accedi al tuo Linux computer.

  1. Installa il driver del filesystem davfs2 di WebDAV, che ti consente di montare le condivisioni WebDAV come ogni altro filesystem remoto. Usa questo comando per installarlo su Debian/Ubuntu:

    apt-get install davfs2
    
  2. Usa questo comando per installarlo su CentOS, Fedora, e openSUSE:

    yum install davfs2
    
  3. Aggiungi il tuo utente al gruppo 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. Copia /etc/davfs2/secrets in ~/.davfs2:

    cp  /etc/davfs2/secrets ~/.davfs2/secrets
    
  6. Impostati come il proprietario e modifica i permessi di lettura-scrittura disponibili solo al proprietario.

    chown <linux_username>:<linux_username> ~/.davfs2/secrets
    chmod 600 ~/.davfs2/secrets
    
  7. Aggiungi le tue credenziali di accesso di Nextcloud alla fine del file secrets, usando l’URL del tuo server Nextcloud e il nome utente e la password di Nextcloud.

    https://example.com/nextcloud/remote.php/dav/files/USERNAME/ <username> <password>
    or
    $PathToMountPoint $USERNAME $PASSWORD
    for example
    /home/user/nextcloud john 1234
    
  8. Aggiungi le informazioni di montaggio a /etc/fstab:

    https://example.com/nextcloud/remote.php/dav/files/USERNAME/ /home/<linux_username>/nextcloud davfs user,rw,auto 0 0
    
  9. Allora verifica che si monti e si autentichi eseguendo i seguenti comandi. Se l’hai impostato correttamente non avrai bisogno dei permessi di root.

    mount ~/nextcloud
    
  10. Dovresti essere in grado anche di smontarlo:

    umount ~/nextcloud
    

Ora, ogni volta che accederai al tuo sistema Linux, la tua condivisione di Nextcloud dovrebbe essere montata automaticamente tramite WebDAV nella tua cartella ~/nextcloud. Se preferisci montarla manualmente, cambia auto in noauto in «/etc/fstab.

Problemi noti

Problema

Risorsa temporaneamente non disponibile

Soluzione

Se riscontri problemi quando crei un file in una cartella, modifica /etc/davfs2/davfs2.conf e aggiungi:

use_locks 0

Problema

Avvisi relativi al certificato

Soluzione

Se utilizzi un certificato di sicurezza auto-firmato, avrai un avviso. Per modificarlo, devi configurare davfs2 in modo da riconoscere il tuo certificato. Copia miocertificato.pem in /etc/davfs2/certs/. Poi modifica /etc/davfs2/davfs2.conf ed elimina il commento della linea servercert. Ora aggiungi il percorso della tua certificazione come nell’esempio.

servercert /etc/davfs2/certs/mycertificate.pem

Accedere ai file usando macOS

Nota

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.

Accedere ai file tramite macOS Finder:

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

    Screenshot dell'inserimento dell'indirizzo del tuo server Nextcloud su 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. Fai clic su Connetti. Il tuo server WebDAV dovrebbe apparire sul desktop come un’unità di disco condivisa.

Accedere ai file usando 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.

L’utilizzo di questa funzionalità richiede una connessione alla rete. Se vuoi archiviati i tuoi file non in linea, usa il Client Desktop per sincronizzare i file nel tuo Nextcloud in una o più cartelle del tuo disco fisso locale.

Nota

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.

Associare drive con la riga di comando

Il seguente esempio mostra come associare un drive usando la riga di comando. Per associare il drive:

  1. Apri il prompt dei comandi su Windows.

  2. Digita la seguente riga nel prompt dei comandi per associare il drive Z del computer:

    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
    

    Il computer associa i file del tuo account Nextcloud al drive con lettera Z.

    Nota

    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.

    Una sintassi di comando alternativa è:

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

Associare i drive con Windows Explorer

To map a drive using Microsoft Windows Explorer:

  1. Apri Esplora risorse sul tuo computer MS Windows.

  2. Fai clic con il tasto destro sulla voce Computer e seleziona Associa drive di rete… dal menu a tendina.

  3. Scegli un drive di rete locale a cui vuoi associare Nextcloud.

  4. Specifica l’indirizzo della tua istanza Nextcloud, seguito da /remote.php/dav/files/NOMEUTENTE/.

    Ad esempio:

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

    Nota

    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. Fai clic sul pulsante Fine.

Windows Explorer associa il drive di rete, rendendo disponibile la tua istanza Nextcloud.

Accedere ai file usando Cyberduck

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

Nota

Questo esempio usa Cyberduck versione 4.2.1.

Per usare 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/

Ora Cyberduck consente l’accesso ai file del server Nextcloud.

Accedere alle risorse pubbliche tramite WebDAV

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

Per accedere alle risorse pubbliche, apri:

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.

Nota

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).

Problemi noti

Problema

Windows non si connette usando HTTPS.

Soluzione 1

Il client WebDAV di Windows potrebbe non supportare il Server Name Indication (SNI) per le connessioni cifrate. Se ricevi un errore montando un’istanza di Nextcloud con protocollo SSL, contatta il tuo provider sull’assegnazione di un indirizzo IP dedicato al tuo server basato su SSL.

Soluzione 2

Il client WebDAV di Windows potrebbe non supportare le connessioni TLSv1.1 e TLSv1.2. Se hai limitato la configurazione del server per fornire solo TLSv1.1 e versioni successive, la connessione al tuo server potrebbe non riuscire. Fai riferimento alla documentazione WinHTTP per ulteriori informazioni.

Problema

Ricevi il seguente messaggio di errore: Errore 0x800700DF: La dimensione del file supera il limite consentito e non può essere salvato.

Soluzione

Windows limita la massima dimensione del file trasferito da o verso una condivisione WebDAV che potrebbe avere. Puoi aumentare il valore FileSizeLimitInBytes in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WebClient\Parameters facendo clic su Modifica.

Per aumentare il limite al valore massimo di 4GB, seleziona Decimal, inserisci il valore 4294967295, e riavvia Windows o riavvia il servizio WebClient.

Problema

L’accesso ai tuoi file da Microsoft Office tramite WebDAV non funziona.

Soluzione

Problemi noti e le loro soluzioni sono documentati nell’articolo KB2123563.

Problema

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

Soluzione

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

  2. Fai clic fino a raggiungere l’errore del certificato nella barra di stato del browser.

  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. Scorri fino a Autorità di certificazione radice attendibili, Certificati.

  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.

Accedere ai file usando cURL

Since WebDAV is an extension of HTTP, cURL can be used to script file operations.

Nota

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.

Per creare una cartella con la data attuale come nome:

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

Per caricare un file error.log in quella cartella:

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

Per spostare un file:

$ 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

Per ottenere le proprietà dei file nella cartella radice:

    $ 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 TSL/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

Nota

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).