Table of Contents
FileBrowser
There are a few software out there, but i like File Browser a lot because it's lightweight, don't get in the way, is flexible and simple to use, but i do not like the default installation method of FileBrowser because it will install system-wide. I will show you how to install in a more customized way.
Installation
Create a standard user to host the FileBrowser installation. You will most probably never run it as this user, but always as different users, to allow it manage files owned by those users.
useradd -d /data/daemons/filebrowser -m filebrowser
The default install approach is based on a auto executable web link (here) which i do not recommend to use directly. Instead go to here and download the proper package for your architecture. Then:
su - filebrowser mkdir bin cd bin tar xvf ../linux-amd64-filebrowser.tar.gz
That's it!
Authentication
filebrowser config set --auth.method=noauth filebrowser config set --auth.method=proxy --auth.header=X-My-Header
TBD
Reverse Proxy
Running FileBrowser behind NGINX is easy, this is an example:
- filebrowser.conf
location /filebrowser/ { client_max_body_size 512M; proxy_pass http://127.0.0.1:3002; proxy_http_version 1.1; proxy_set_header Connection $http_connection; proxy_set_header Connection 'upgrade'; proxy_cache_bypass $http_upgrade; 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; #proxy_set_header Authorization $remote_user; }
Remember to set the correct port as each instance of FileBrowser will have to run with it's own port, and set a reasonable location URL. This setup will also make use of FileBrowser user intergation with Proxy Authentication, if used, by uncommenting the last line.
Running
I assume you want to run it as user myuser.
As a general startup rule, the first time you need to run it once to create the needed configuration files and database, then you want to start it with a script and have it start automatically at boot.
For initial configuration:
su - myuser /data/daemons/filebrowser/bin/filebrowser -r "/data/MyFiles" -p 3005 -d "/home/myuser/filebrowser.db"
As the starting script, since i use OpenRC, i have written the following init script wihch needs to be dropped to /etc/init.d/filebrowser:
#!/sbin/openrc-run # Copyright 2024 Willy Garidol # Distributed under the terms of the GNU General Public License v3 depend() { need localmount net } FB_LOG_PATH="/var/log/filebrowser" FB_SLOT="${SVCNAME#filebrowser.}" FB_USER=${USER:-${FB_SLOT}} FB_GROUP=${GROUP:-${FB_SLOT}} description=${DESCRIPTION:-Web based Filebrowser} pidfile="/run/${RC_SVCNAME}.pid" command_background=true command="/data/daemons/filebrowser/bin/filebrowser" command_args="-r ${FOLDER} -p ${PORT} -b ${BASE_URL} -d ${DATABASE} -l ${FB_LOG_PATH}/${FB_SLOT}/filebrowser.log" command_user="${FB_USER}:${FB_GROUP}" start_pre() { if [ "${FB_SLOT}" != "filebrowser" ] then test -e "${FB_LOG_PATH}" || mkdir "${FB_LOG_PATH}" test -e "${FB_LOG_PATH}/${FB_SLOT}" || { mkdir "${FB_LOG_PATH}/${FB_SLOT}" } && chown -R ${FB_USER} "${FB_LOG_PATH}/${FB_SLOT}" else ebegin "Error: do not run this script, run a link to it!" eend 255 fi }
make it executable!
Now, create a file /etc/conf.d/filebrowser.myshare:
BASE_URL="/files/MyFiles" DATABASE="/homr/myuser/filebrowser.db" DESCRIPTION="Common web archive" FOLDER="/data/MyFiles" GROUP="users" PORT=3005 USER="filebrowser"
And create the symlink, start it and add to autostart:
ln -s /etc/init.d/filebrowser /etc/init.d/filebrowser.myshare rc-update add filebrowser.myshare default /etc/init.d/filebrowser.myshare start
To add more shares, just create new links to the filebrowser init script and create the associated config file.
Updates
Download a new binary release (see link above), replace binary and restart service.