This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| computing:filebrowser [2025/12/09 03:08] – created oemb1905 | computing:filebrowser [2025/12/13 06:18] (current) – oemb1905 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ------------------------------------------- | ||
| + | * **Setting up a secure & public-facing Filebrowser instance** | ||
| + | * **oemb1905** | ||
| + | * **filebrowser-pub** | ||
| + | * **webmaster@gnulinux.studio** | ||
| + | ------------------------------------------- | ||
| + | // | ||
| - | 1. Install File Browser (latest) | + | ------------------------------------------- |
| - | ```bash | + | |
| - | | + | This tutorial is for Debian Trixie users seeking to set up a secure and public-facing [[https:// |
| - | ``` | + | |
| + | | ||
| + | sudo mkdir -p / | ||
| + | sudo chown -R filebrowser: | ||
| + | sudo chmod 755 / | ||
| + | adduser navidrome filebrowser | ||
| + | adduser jellyfin filebrowser | ||
| + | |||
| + | The system will give you an auto-generated user and password upon completion of the installer. Let's change that before we proceed: | ||
| + | |||
| + | sudo systemctl stop filebrowser | ||
| + | sudo filebrowser users update admin --password yournewpassword | ||
| + | sudo systemctl start filebrowser | ||
| + | |||
| + | Make sure to pick a 16+ character password; this is public facing. To be clear, this is invoking the '' | ||
| - | 2. Create system user | ||
| - | | ||
| sudo adduser --system --group --no-create-home filebrowser | sudo adduser --system --group --no-create-home filebrowser | ||
| - | ``` | ||
| - | 3. Install | + | Once the dedicated user is created, let's create the systemd unit to control starting/ |
| - | ```bash | + | |
| - | | + | <code bash> |
| - | ``` | + | [Unit] |
| + | Description=File Browser | ||
| + | After=network.target | ||
| + | |||
| + | [Service] | ||
| + | User=filebrowser | ||
| + | Group=filebrowser | ||
| + | WorkingDirectory=/ | ||
| + | ExecStart=/ | ||
| + | --address 127.0.0.1 \ | ||
| + | --port 8080 \ | ||
| + | --root / | ||
| + | --database / | ||
| + | Restart=always | ||
| + | RestartSec=5 | ||
| + | |||
| + | [Install] | ||
| + | WantedBy=multi-user.target | ||
| + | </ | ||
| + | |||
| + | Once that's in place, load the unit and start the service: | ||
| + | |||
| + | sudo systemctl daemon-reload | ||
| + | sudo systemctl enable --now filebrowser | ||
| + | |||
| + | Make sure to customize the unit file for your own use-case. For example, you might have a different startup directory, different listening port, and so on. Once the unit file is created and the service has started, let's make sure that ACL is installed so we can set a custom rule for the filebrowser UNIX user, which the filebrowser' | ||
| + | |||
| + | | ||
| + | sudo setfacl -R -m u: | ||
| + | sudo setfacl -R -m d: | ||
| + | |||
| + | UPDATE: This is actually overkill. You can simply: | ||
| + | sudo chown -R filebrowser: | ||
| + | |||
| + | Bear in mind, however, that new files will be owned by filebrowser: | ||
| + | |||
| + | This assumes ''/ | ||
| + | |||
| + | sudo apt install certbot letsencrypt python3-certbot-apache | ||
| + | sudo certbot --authenticator standalone --installer apache -d domain.com --pre-hook " | ||
| + | |||
| + | This will create another virtual host at '' | ||
| + | |||
| + | <code bash> | ||
| + | < | ||
| + | ServerName upload.gnulinux.studio | ||
| + | RewriteEngine On | ||
| + | RewriteRule ^ https:// | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | Now, let's do the same trick with the https virtual host. Open up '' | ||
| + | |||
| + | <code bash> | ||
| + | < | ||
| + | ServerName upload.gnulinux.studio | ||
| + | SSLEngine on | ||
| + | SSLCertificateFile | ||
| + | SSLCertificateKeyFile | ||
| + | |||
| + | ProxyPreserveHost On | ||
| + | ProxyPass / http:// | ||
| + | ProxyPassReverse / http:// | ||
| + | |||
| + | RewriteEngine On | ||
| + | RewriteCond %{HTTP: | ||
| + | RewriteCond %{HTTP: | ||
| + | RewriteRule ^/?(.*) ws:// | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | Once this is done, you should be good to go. Make sure that: | ||
| - | 4. Systemd unit (final working version) | + | * If you already using domain.com, then change the above to sub.domain.com |
| - | `/etc/ | + | * LAMP stack won't work unless all modules, headers, and mpm_event/fpm working |
| - | ```ini | + | * Have fail2ban configured |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | This tutorial is not designed to provide a full tutorial on these topics, but generally these modules are enough: |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | sudo a2enmod proxy |
| - | ``` | + | sudo a2enmod proxy_http |
| - | ```bash | + | sudo a2enmod proxy_wstunnel |
| - | | + | sudo a2enmod headers |
| - | | + | sudo a2enmod rewrite |
| - | ``` | + | sudo a2enmod remoteip |
| + | sudo a2enmod proxy_fcgi | ||
| + | sudo a2enmod setenvif | ||
| - | 5. Give File Browser permanent write access to the existing Navidrome library | + | If you need more guidance, see the Apache Survival Tutorial already linked at the top. If you need help with mpm_event and fpm, use my [[https://wiki.haacksnetworking.org/doku.php? |
| - | | + | |
| - | sudo setfacl -R -m u:filebrowser: | + | |
| - | sudo setfacl -R -m d:u:filebrowser: | + | |
| - | ``` | + | |
| - | 6. Apache reverse-proxy vhosts (already present) | + | <code bash> |
| + | [filebrowser] | ||
| + | enabled = true | ||
| + | backend = systemd | ||
| + | port = 8080 | ||
| + | filter = filebrowser | ||
| + | logpath = / | ||
| + | maxretry = 3 | ||
| + | findtime = 600 | ||
| + | bantime = 3600 | ||
| + | action = iptables-allports[name=filebrowser] | ||
| + | </ | ||
| - | HTTP → HTTPS redirect | + | After the jail is established, |
| - | | + | |
| - | | + | |
| - | < | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | </ | + | |
| - | ``` | + | |
| - | HTTPS reverse proxy | + | <code bash> |
| - | `nano / | + | [INCLUDES] |
| - | | + | before = common.conf |
| - | <VirtualHost *:443> | + | [Definition] |
| - | ServerName upload.gnulinux.studio | + | datepattern = ^%%Y/%%m/%%d %%H: |
| - | SSLEngine on | + | failregex = /api/login: 403 < |
| - | SSLCertificateFile | + | ignoreregex = |
| - | SSLCertificateKeyFile | + | </code> |
| - | | + | Make sure to adjust bantime, maxretry, and findtime to your preferences. Also, apache-auth' |
| - | | + | |
| - | | + | |
| - | | + | <code bash> |
| - | RewriteCond %{HTTP: | + | [apache-auth] |
| - | RewriteCond %{HTTP: | + | enabled = true |
| - | RewriteRule ^/?(.*) ws://127.0.0.1: | + | port = http, |
| - | | + | filter = apache-auth |
| - | ``` | + | logpath = /var/log/apache2/error.log |
| + | maxretry = 5 | ||
| + | findtime = 600 | ||
| + | bantime = 3600 | ||
| + | action = iptables-allports[name=apache-auth] | ||
| + | </code> | ||
| - | Done. | + | Now, for the filter, let's open '' |
| - | https:// | + | |
| - | Everything appears | + | |
| - | ### One-page note to yourself | + | <code bash> |
| + | [Definition] | ||
| + | failregex = ^< | ||
| + | ^< | ||
| + | ignoreregex = | ||
| + | </ | ||
| - | This entire setup lives on the **exact same VM** `gnulinux.studio` that already runs Navidrome | + | This creates a separate jail for common errors brute-forcers will receive when they are trying to access your instance' |
| - | - Navidrome is reachable at https:// | + | Happy Hacking !!! |
| - | - File Browser is reachable at https:// | + | |
| - | - File Browser’s `--root` points directly at `/ | + | |
| - | - Write access for the `filebrowser` system user is granted **exclusively** by two ACL commands: | + | |
| - | ```bash | + | |
| - | setfacl -R -m u: | + | |
| - | setfacl -R -m d: | + | |
| - | ``` | + | |
| - | No group membership, no setgid, no cron required for functionality. | + | |
| - | - Navidrome continues to own most files and always has group `navidrome`, | + | |
| - | - File Browser creates files as `filebrowser: | + | |
| - | --- // | + | --- // |