Base de connaissances

Snapdrop Print

  • 0

How to Install SnapDrop on Ubuntu 24.04

SnapDrop is a self-hosted, browser-based file sharing platform similar to AirDrop. It allows fast and private file transfers over your local network using just a web browser — no external servers required.

In this guide, learn how to install and configure SnapDrop on Ubuntu 24.04 LTS using Node.js, Nginx, and systemd for a lightweight and reliable setup.

 

Prerequisites

Before starting, ensure the following:

  • A clean Ubuntu 24.04 system

  • Sudo or root access

  • Port 80 open for HTTP traffic



Step 1: Update System Packages

sudo apt update && sudo apt upgrade -y


Step 2: Install Dependencies

Install the required packages for Node.js, Nginx, and Git.

sudo apt install -y git nginx nodejs npm ufw

 

Step 3: Create a System User for SnapDrop

sudo useradd -r -m -d /home/snapdrop -s /bin/bash snapdrop

 

Step 4: Clone the SnapDrop Repository

sudo rm -rf /var/www/snapdrop
sudo mkdir -p /var/www
sudo git clone https://github.com/snapdrop/snapdrop.git /var/www/snapdrop
sudo chown -R snapdrop:snapdrop /var/www/snapdrop

 

Step 5: Install Node Dependencies

cd /var/www/snapdrop/server
npm install --omit=dev

 

Step 6: Create a systemd Service

Create the service file to run SnapDrop automatically on startup.
sudo tee /etc/systemd/system/snapdrop.service > /dev/null <<EOF
[Unit]
Description=SnapDrop self-hosted file sharing
After=network.target

[Service]
Type=simple
User=snapdrop
WorkingDirectory=/var/www/snapdrop/server
ExecStart=/usr/bin/node index.js
Restart=always
RestartSec=3
Environment=PORT=3000
Environment=NODE_ENV=production

[Install]
WantedBy=multi-user.target
EOF
Then enable and start the service:
sudo systemctl daemon-reload
sudo systemctl enable snapdrop
sudo systemctl start snapdrop

 

Step 7: Configure Nginx

Remove any conflicting site configurations and create a new one for SnapDrop.
sudo rm -f /etc/nginx/sites-enabled/default
sudo tee /etc/nginx/sites-available/snapdrop > /dev/null <<EOF
server {
    listen 80;
    server_name _;

    root /var/www/snapdrop/client;
    index index.html;

    location / {
        try_files \$uri \$uri/ /index.html;
    }

    location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
        expires 1y;
        add_header Cache-Control "public, immutable";
    }
}
EOF

sudo ln -s /etc/nginx/sites-available/snapdrop /etc/nginx/sites-enabled/snapdrop
sudo nginx -t
sudo systemctl restart nginx

 

Step 8: Configure UFW Firewall
sudo ufw enable
sudo ufw allow 22/tcp
sudo ufw allow 80/tcp

 

Step 9: Access SnapDrop

Once installation is complete, open your browser and navigate to:
http://<your-server-ip>

 

Conclusion

SnapDrop offers an elegant way to share files instantly over your local network using only a browser.
With Node.js, Nginx, and systemd, this setup ensures your instance is fast, secure, and always running.

 

You now have a fully functional SnapDrop instance hosted on Ubuntu 24.04 — perfect for private, seamless file sharing within your network.


Cette réponse était-elle pertinente?
Back