I implemented a somewhat complicated solution using a separate VM for this, based on the instructions linked below. I did it this way because printers are a security nightmare and I would never let my printer access my Nextcloud VM or my Nextcloud directly, even if it would support WebDAV 
https://thesmarthomejourney.com/2021/12/04/automatic-upload-to-nextcloud/
https://github.com/OliverHi/autouploader
Below i pasted my documentation on how I impemented it, maybe it is of any help:
Scan 2 Cloud
1. Preparations
Setup a separate server or VM and execute the following commands:
sudo apt install samba rclone inotify-tools git
sudo adduser --no-create-home --disabled-password --disabled-login scanner
sudo mkdir /opt/scans
sudo chown scanner /opt/scans/
sudo smbpasswd -a scanner
2. Setup Samba
sudo nano /etc/samba/smb.conf
Comment out the [printers]
and [print$]
sections like in the example below, or just delete them:
;[printers]
; comment = All Printers
; browseable = no
; path = /var/spool/samba
; printable = yes
; guest ok = no
; read only = yes
; create mask = 0700
# Windows clients look for this share name as a source of downloadable
# printer drivers
;[print$]
; comment = Printer Drivers
; path = /var/lib/samba/printers
; browseable = yes
; read only = yes
; guest ok = no
Add the following lines to the end of the file:
[scans]
comment = Scans folder
path = /opt/scans/
force user = scanner
force group = scanner
writeable = yes
valid users = scanner
If your scanner doesn’t support modern samba versions, add the following line to the [global] section of the file:
server min protocol = NT1
Restart the smb deanon:
sudo systemctl restart smbd.service
3. Configure Rclone
Create a folder “Scans” and an App-Password on the Nextcloud account you want to scan to. After that you can configure Rclone by typing rclone config
and following the instruchtions:
rclone config
n) New remote
d) Delete remote
r) Rename remote
c) Copy remote
s) Set configuration password
q) Quit config
e/n/d/r/c/s/q> n
name> Nextcloud
Type of storage to configure.
Enter a string value. Press Enter for the default ("").
Choose a number from below, or type in your own value
[...]
31 / Webdav
\ "webdav"
[...]
Storage> 31
** See help for webdav backend at: https://rclone.org/webdav/ **
URL of http host to connect to
Enter a string value. Press Enter for the default ("").
Choose a number from below, or type in your own value
1 / Connect to example.com
\ "https://example.com"
url> https://cloud.yourdomain.tld/remote.php/dav/files/your-nextcloud-username/Scans
Name of the Webdav site/service/software you are using
Enter a string value. Press Enter for the default ("").
Choose a number from below, or type in your own value
1 / Nextcloud
\ "nextcloud"
2 / Owncloud
\ "owncloud"
3 / Sharepoint
\ "sharepoint"
4 / Other site/service or software
\ "other"
vendor> 1
User name
Enter a string value. Press Enter for the default ("").
user> your-nextcloud-username
Password.
y) Yes type in my own password
g) Generate random password
n) No leave this optional password blank (default)
y/g/n> y
Enter the password:
password: *the-app-password-previously-generatetd*
Confirm the password:
password: *the-app-password-previously-generatetd*
Bearer token instead of user/pass (eg a Macaroon)
Enter a string value. Press Enter for the default ("").
bearer_token> press ENTER
Edit advanced config? (y/n)
y) Yes
n) No (default)
y/n> n
Remote config
--------------------
[Nextcloud]
url = https://cloud.yourdomain.tld/remote.php/dav/files/your-nextcloud-username/Scans
vendor = nextcloud
user = your-nextcloud-username
pass = *** ENCRYPTED ***
--------------------
y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote
y/e/d> y
Current remotes:
Name Type
==== ====
Nextcloud webdav
e) Edit existing remote
n) New remote
d) Delete remote
r) Rename remote
c) Copy remote
s) Set configuration password
q) Quit config
e/n/d/r/c/s/q> q
4. Setup the Inotify Tools
Clone the repository:
sudo git clone https://github.com/OliverHi/autouploader.git /opt/autouploader
Change the value of the DOCUMENT_PATH
setting to: /opt/scans
in /opt/autouploader/autoupload.sh
:
sudo nano /opt/autouploader/autoupload.sh
[...]
# configuration
DOCUMENT_PATH="/opt/scans/"
[...]
Copy your rclone config…
sudo cp ~/.config/rclone/rclone.conf /opt/autouploader/rclone.conf
…and update the ownership:
sudo chown scanner /opt/autouploader/rclone.conf
Install this script as a background service:
sudo ln -s /opt/autouploader/autouploader.service /etc/systemd/system/autouploader.service
sudo systemctl daemon-reload
Enable the service:
sudo systemctl enable autouploader.service
Start the service:
sudo systemctl start autouploader.service
Make sure the service is running:
sudo systemctl status autouploader.service
Check the logs:
journalctl -u autouploader.service -f
Sources: