UpSnap Documentation

repository·master·Indexed 26 days ago

https://github.com/seriousm4x/upsnap

UpSnap is a self-hostable Wake-on-LAN web application built with SvelteKit, Go, and PocketBase. It features a dashboard for one-click device wake-up, scheduled automation via Cron, and device shutdown capabilities. The documentation covers installation via binary, Docker, and AUR, as well as reverse proxy configuration with Caddy and Nginx, and detailed Docker environment variables for network scanning and WOL functionality.

Tokens
2.8K
Snippets
16
Records
23
Agent score
92%

What's inside UpSnap

  1. Run UpSnap in a sub-path with Reverse Proxies

    master

    If you need to host UpSnap on a sub-path (e.g., /upsnap-sub-path/), ensure the path ends with a trailing /. Below are examples for Caddy and Nginx.

    # Caddy example
    http://localhost:8091 {
        handle /upsnap-sub-path/* {
            uri strip_prefix /upsnap-sub-path
            reverse_proxy localhost:8090
        }
    }
    # Nginx example
    http {
        server {
            listen 8091;
            server_name localhost;
            location /upsnap-sub-path/ {
                proxy_pass http://localhost:8090/;
                proxy_redirect off;
                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Forwarded-Proto $scheme;
            }
        }
    }
  2. Build and preview the production application

    master
    To generate a production-ready version of the application, run npm run build. You can then use npm run preview to test the production build locally. Note that for deployment, you may need to install a SvelteKit adapter specific to your target environment.
    npm run build
    
    npm run preview
  3. Run the UpSnap binary

    master

    To run UpSnap directly from a downloaded binary, use the serve command. You can specify the listening address and port using the --http flag. Note that running on certain ports or performing certain network tasks may require sudo.

    sudo ./upsnap serve --http=0.0.0.0:8090
  4. Initialize a new Svelte project

    master

    Use npm create svelte@latest to scaffold a new Svelte project. You can either initialize it in the current directory or specify a directory name.

    # create a new project in the current directory
    npm create svelte@latest
    
    # create a new project in my-app
    npm create svelte@latest my-app
  5. Develop the frontend application

    master

    After creating the project and installing dependencies via npm install, pnpm install, or yarn, start the development server using npm run dev. To automatically open the application in a new browser tab, use the --open flag.

    npm run dev
    
    # or start the server and open the app in a new browser tab
    npm run dev -- --open
  6. Run UpSnap in Docker

    master

    You can run UpSnap using Docker by pulling the latest image. It is recommended to use --network=host to ensure the application can perform network scanning and Wake-on-LAN functionality effectively.

    docker run --network=host seriousm4x/upsnap:latest
  7. Configure UpSnap port in Docker

    master

    To change the default listening port (8090) when running via Docker, set the UPSNAP_HTTP_LISTEN environment variable in your configuration (e.g., in a docker-compose.yml file).

    environment:
      - UPSNAP_HTTP_LISTEN=0.0.0.0:5000
  8. Run the UpSnap backend

    master
    The UpSnap backend is built on top of PocketBase. To start the application, the entrypoint executes pb.StartPocketBase, passing in the embedded static files located in the pb_public directory. This initializes the PocketBase server with the necessary frontend assets embedded within the binary.
  9. Required Docker Capabilities and Network Mode

    master

    For UpSnap to function correctly (specifically for privileged pings, network device scanning via nmap, and Wake-on-LAN), the following Docker settings are required:

    • network_mode: host: Required for WOL magic packets.
    • cap_add: [NET_RAW]: Required for privileged ping and network device scan (nmap).
    • cap_drop: [ALL]: Recommended for security.
    services:
      upsnap:
        cap_add:
          - NET_RAW
        cap_drop:
          - ALL
        network_mode: host