User Tools

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
services:filebrowser [2024/03/22 07:59] – created willyservices:filebrowser [2025/01/21 11:50] (current) – [Running] willy
Line 1: Line 1:
-===== Fileserver access via Browser =====+===== FileBrowser =====
  
 There are a few software out there, but i like [[https://filebrowser.org/|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. There are a few software out there, but i like [[https://filebrowser.org/|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.
  
-//FileBrowser// will run as the **fileserver** user that you created above. You will need to create the following folders architecture in your *fileserver* home folder: +==== Installation ====
-- bin: where the FileBrowser binary will be located +
-- data/db: where the FileBrowser databases files will be stored +
-- data/logs: where the various log files will be created+
  
-You need to set the //umask// for the user to **0002** so that any new files created by it will be writable by the users.+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.
  
-Then, as //fileserver// user, get the software package and decompress it. The default install approach is based on a auto executable web link ([[https://raw.githubusercontent.com/filebrowser/get/master/get.sh|here]]) which i do not recommend to use directly. Instead go to [[https://github.com/filebrowser/filebrowser/releases/|here]] and download the proper package for your architecture. Then: 
 <code bash> <code bash>
-su fileserver +useradd -d /data/daemons/filebrowser -m filebrowser 
-echo "umask 0002" >~/.bashrc +</code> 
-source ~/.bashrc + 
-mkdir bin data data/logs data/db+The default install approach is based on a auto executable web link ([[https://raw.githubusercontent.com/filebrowser/get/master/get.sh|here]]) which i do not recommend to use directly. Instead go to [[https://github.com/filebrowser/filebrowser/releases/|here]] and download the proper package for your architecture. Then: 
 +<code bash> 
 +su - filebrowser 
 +mkdir bin
 cd bin cd bin
 tar xvf ../linux-amd64-filebrowser.tar.gz tar xvf ../linux-amd64-filebrowser.tar.gz
 </code> </code>
  
-Now, you will need to start copy of FileBrowser for each share you want to have, and it must be owned by the user that want file permissions on that shareTo achieve this, you will be using special script called **fileserver.sh** which i will show you at the endbecause it will contain also the WebDAV start stuff in it.+That's it!  
 + 
 +In addition you might want to create the following **.bashrc**: 
 +<file - .bashrc> 
 +#!/bin/bash 
 + 
 +export UMASK=0002 
 +export PATH=$PATH:~/bin 
 +</file> 
 + 
 +==== Authentication ==== 
 + 
 +<code bash> 
 +filebrowser config set --auth.method=noauth 
 +filebrowser config set --auth.method=proxy --auth.header=X-My-Header 
 +</code> 
 + 
 +TBD 
 + 
 +==== Reverse Proxy ==== 
 + 
 +Running FileBrowser behind NGINX is easy, this is an example: 
 +<file - 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; 
 + 
 +    } 
 +</file> 
 + 
 +Remember to set the correct port as each instance of FileBrowser will have to run with it's own port, and set 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 rulethe 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: 
 +<code bash> 
 +su - myuser 
 +/data/daemons/filebrowser/bin/filebrowser -r "/data/MyFiles" -p 3005 -d "/home/myuser/filebrowser.db" 
 +</code> 
 + 
 +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**
 +<file 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 scriptrun a link to it!" 
 +                eend 255 
 +        fi 
 +
 +</file> 
 + 
 +make it executable! 
 + 
 +Now, create a file **/etc/conf.d/filebrowser.myshare**: 
 +<file filebrowser.myshare> 
 +BASE_URL="/files/MyFiles" 
 +DATABASE="/homr/myuser/filebrowser.db" 
 +DESCRIPTION="Common web archive" 
 +FOLDER="/data/MyFiles" 
 +GROUP="users" 
 +PORT=3005 
 +USER="filebrowser" 
 +</file> 
 + 
 +And create the symlink, start it and add to autostart: 
 +<code bash> 
 +ln -s /etc/init.d/filebrowser  /etc/init.d/filebrowser.myshare 
 +rc-update add filebrowser.myshare default 
 +/etc/init.d/filebrowser.myshare start 
 +</code> 
 + 
 +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. 

This website uses technical cookies only. No information is shared with anybody or used in any way but provide the website in your browser.

More information