A static site has no server-side code, so a password-protected upload area normally means dragging in PHP or a whole cloud suite. dufs is a single Rust binary that serves one directory over HTTP - upload, download, delete, archive - with its own logins, independent of the Linux users. It listens on localhost only; nginx publishes it under a path on the existing site and lends it that site’s TLS certificate. fail2ban then watches the login for brute force.

Everything below runs on the server, over SSH; the local machine is not touched. The commands are written for a normal user with sudo - in a root shell they work unchanged, just drop every sudo. Step 1 is the one worth doing as a normal user: it downloads an archive from the internet and runs the binary out of it, which is no job for root. Written for dufs 0.46.0 on Ubuntu 24.04 with nginx + certbot.

Step 1 - Download and verify

This only touches /tmp, nothing is installed yet:

cd /tmp
V=v0.46.0
U=https://github.com/sigoden/dufs/releases/download
wget $U/$V/dufs-$V-x86_64-unknown-linux-musl.tar.gz
sha256sum dufs-*.tar.gz

The checksum must start with 817769f7 and end with 2f410977 - that is what GitHub has on record for this file. If it differs, stop here.

tar xzf dufs-*.tar.gz
./dufs --version

prints dufs 0.46.0. V and U are shell variables, so step 1 and 2 belong in the same session.

Step 2 - Install the binary

sudo install -m 755 dufs /usr/local/bin/dufs
There is no apt package; later upgrades replace this single file.

Step 3 - User and folder

A system user without a login shell, owning the data directory:

sudo useradd -r -s /usr/sbin/nologin -d /srv/drop dufs
sudo install -d -m 750 -o dufs -g dufs /srv/drop

Step 4 - Password and config

dufs keeps its logins in its own config, as name:hash@path:permissions. Create the hash:
openssl passwd -6
It asks for the password twice and prints a line starting with $6$. Copy that line, then:
sudo nano /etc/dufs.yaml
Paste this, replacing the placeholder with your own hash and keeping the single quotes:

serve-path: /srv/drop
bind: 127.0.0.1
port: 5000
path-prefix: /drop
auth:
  - 'dropuser:$6$PASTE_YOUR_HASH_HERE@/:rw'
allow-upload: true
allow-delete: true
allow-search: true
allow-archive: true

The file holds a password hash, so keep it off the world:

sudo chown root:dufs /etc/dufs.yaml
sudo chmod 640 /etc/dufs.yaml

Note that bind: 127.0.0.1 keeps dufs unreachable from outside - only nginx talks to it. And path-prefix must match the nginx location, or every link and redirect dufs builds points at the wrong place.

Step 5 - systemd service

Create the unit:
sudo nano /etc/systemd/system/dufs.service
and paste:

[Unit]
Description=dufs file drop
After=network.target

[Service]
User=dufs
Group=dufs
ExecStart=/usr/local/bin/dufs --config /etc/dufs.yaml
Restart=on-failure
NoNewPrivileges=yes
ProtectSystem=strict
ProtectHome=yes
ReadWritePaths=/srv/drop
PrivateTmp=yes
PrivateDevices=yes
ProtectKernelTunables=yes
ProtectKernelModules=yes
ProtectControlGroups=yes
RestrictNamespaces=yes
LockPersonality=yes
MemoryDenyWriteExecute=yes
CapabilityBoundingSet=
RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX AF_NETLINK

[Install]
WantedBy=multi-user.target

Then start it and check that it answers:

sudo systemctl daemon-reload
sudo systemctl enable --now dufs
curl -sI http://127.0.0.1:5000/drop/ | head -1

That must print HTTP/1.1 401 Unauthorized - running, and asking for a login.

Step 6 - Connect nginx

Back the site config up first, outside the nginx folders:

sudo cp /etc/nginx/sites-available/example.com /root/
sudo nano /etc/nginx/sites-available/example.com

Add only the location /drop/ block, directly below the existing location / block, in the server block that carries the certificate:

server {
    server_name example.com www.example.com;

    root /var/www/example.com;

    location / {
        try_files $uri $uri/ =404;
    }

    location /drop/ {
        proxy_pass http://127.0.0.1:5000;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header X-Forwarded-Proto $scheme;
        client_max_body_size 5G;
        proxy_request_buffering off;
        proxy_buffering off;
        proxy_read_timeout 1h;
        proxy_send_timeout 1h;
    }

    listen [::]:443 ssl ipv6only=on; # managed by Certbot
    ... (rest unchanged)
}

Leave everything else alone, the second server block (the port 80 redirect) included. Then:

sudo nginx -t
sudo systemctl reload nginx

The test must report “syntax is ok” and “test is successful” - only then reload.

What the proxy lines are for:

  • client_max_body_size - nginx’s default is 1 MB, so without it every larger upload dies with 413. 5G is the cap chosen here.
  • proxy_request_buffering off - otherwise nginx spools the complete upload to disk before passing it on: twice the disk traffic, and a progress bar stuck at 100 %.
  • the two timeouts - the 60 s default aborts slow large transfers.

Step 7 - Test

Open the site’s address followed by /drop/ in a browser, log in with the name and password from step 4, upload a file on one device and download it on the other. The two devices never need a terminal - a browser is enough.

Step 8 - fail2ban against password guessing

Basic auth invites brute force, so count the 401s in nginx’s access log. Create the filter:
sudo nano /etc/fail2ban/filter.d/nginx-drop.conf
with:

[Definition]
failregex = ^<HOST> \S+ \S+ \[[^\]]*\] "[A-Z]+ /drop/\S* HTTP/[0-9.]+" 401\s
ignoreregex =

And the jail:
sudo nano /etc/fail2ban/jail.d/nginx-drop.conf
with:

[nginx-drop]
enabled  = true
port     = http,https
filter   = nginx-drop
logpath  = /var/log/nginx/access.log
# defaults-debian.conf sets backend = systemd; this jail reads a file
backend  = auto
maxretry = 10
findtime = 10m
bantime  = 1h

Activate and check:

sudo systemctl restart fail2ban
sudo fail2ban-client status nginx-drop

Unban an address again:
sudo fail2ban-client set nginx-drop unbanip 198.51.100.7

Pitfalls

  • AF_NETLINK must stay in RestrictAddressFamilies. Without it dufs aborts at startup with “Failed to get local interface addresses” - it enumerates the interfaces to print its listen URLs, and that needs a netlink socket.
  • ProtectSystem=strict makes the whole filesystem read-only, so /srv/drop has to be named in ReadWritePaths or uploads fail.
  • backend = auto in the jail is not optional: jail.d/defaults-debian.conf sets backend = systemd globally, and with that backend a jail reading a log file silently never matches anything.
  • One ordinary visit already causes one 401 - a browser only sends credentials after it has been challenged. A tight maxretry therefore bans legitimate users; 10 in 10 minutes is roomy and still stops guessing.
  • nginx -t must run with sudo, it needs to read the TLS private key.
  • The fail2ban startup warning “‘allowipv6’ not defined” is harmless.

Maintenance

  • Another login: one more entry under auth:, then restart.
  • Nothing expires by itself - clear /srv/drop out now and then.
  • Logs: journalctl -u dufs for the service, /var/log/nginx/access.log for the requests.

Keeping dufs up to date

dufs has no apt or distro package - the binary was placed by hand, so nothing but you updates it and apt upgrade never touches it. Check https://github.com/sigoden/dufs/releases now and then; a release with security fixes is worth a few minutes. Upgrading is just the install again:

1. Download the latest release and verify it (as in step 1), replacing the version:

cd /tmp
V=v0.47.0
U=https://github.com/sigoden/dufs/releases/download
wget $U/$V/dufs-$V-x86_64-unknown-linux-musl.tar.gz
sha256sum dufs-*.tar.gz

Compare the sum with the one GitHub lists for the file; if it differs, stop.

2. Unpack it:
tar xzf dufs-*.tar.gz

3. Install over the old binary and restart:

sudo install -m 755 dufs /usr/local/bin/dufs
sudo systemctl restart dufs

Check it came back: dufs --version, and curl -sI http://127.0.0.1:5000/drop/ | head -1 should print HTTP/1.1 401 Unauthorized.

Undo - only if the drop should go away again

None of this belongs to the install. Run it only when you want the file drop removed; otherwise skip the section entirely. Copy anything you still need out of /srv/drop first - the commands below delete it.

Stop the service and put the old site config back:

sudo systemctl disable --now dufs
sudo cp /root/example.com /etc/nginx/sites-available/
sudo nginx -t
sudo systemctl reload nginx

The drop is off the site from here on. The rest only clears the leftovers:

sudo rm /usr/local/bin/dufs /etc/dufs.yaml
sudo rm /etc/systemd/system/dufs.service
sudo systemctl daemon-reload
sudo rm -rf /srv/drop
sudo userdel dufs

And the fail2ban jail, which now watches a path that no longer exists:

sudo rm /etc/fail2ban/jail.d/nginx-drop.conf
sudo rm /etc/fail2ban/filter.d/nginx-drop.conf
sudo systemctl restart fail2ban