We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

How to Install File Browser on Ubuntu 22.04 with Nginx

File Browser is a file managing application which provides a modern interface within a specified directory to upload, delete, preview, rename and edit your files. It also allows creation of multiple users and and assign each user their own directory. With this application you can eliminate the use of chroot setup which is used for managing files alone.

In this guide you are going to learn how to install File browser on Ubuntu 22.04 and configure it with Nginx reverse proxy. We will also create a configuration file to specify the root directory and a systemd file to start file browser as a service using a specific user which Nginx uses www-data.

Initial Setup

Start by updating your server packages to the latest version available.

sudo apt update
sudo apt upgrade -y

Install File Browser

Execute the below command to install File Browser.

curl -fsSL https://raw.githubusercontent.com/filebrowser/get/master/get.sh | bash

Once file browser is installed, you can start it using the filebrowser command to check how it works.

filebrowser -r /path/to/your/files

By default file browser runs on port 8080. You can use your IP address with port 8080 to view the user interface in your browser.

Create Systemd Configuration

Now we shall create a systemd configuration file so that you can use File Browser as a service.

Create a new file named filebrowser.service

sudo nano /etc/systemd/system/filebrowser.service

Add the following to the file.

[Unit]
Description=File browser: %I
After=network.target

[Service]
User=www-data
Group=www-data
ExecStart=/usr/local/bin/filebrowser -c /etc/filebrowser/default.json

[Install]
WantedBy=multi-user.target

Save and Exit the file.

Create File Browser Configuration

Create a new directory mentioned in your systemd file for file browser.

sudo mkdir /etc/filebrowser

Create a new file named default.json

sudo nano /etc/filebrowser/default.json

Add the following to the file.

{
  "port": 8080,
  "baseURL": "",
  "address": "",
  "log": "stdout",
  "database": "/etc/filebrowser/filebrowser.db",
  "root": "/var/www/html/"
}

Save the file and exit.

The filebrowser.db should be located in your home directory ~/

Move the file to the directory we created above.

sudo mv ~/filebrowser.db /etc/filebrowser

Configure correct permissions for database.

sudo chown -R www-data:www-data /etc/filebrowser/filebrowser.db

Now we have all configurations in place.

Start File browser

Enable file browser to start at system boot.

sudo systemctl enable filebrowser

Now you can start filebrowser.

sudo service filebrowser start

You can check the status using the below command.

sudo service filebrowser status
● filebrowser.service - File browser: 
     Loaded: loaded (/etc/systemd/system/filebrowser.service; enabled; vendor preset: enabled)
     Active: active (running) since Mon 2022-11-21 09:12:33 UTC; 4min 21s ago
   Main PID: 462 (filebrowser)
      Tasks: 7 (limit: 1149)
     Memory: 14.0M
        CPU: 34ms
     CGroup: /system.slice/filebrowser.service
             └─462 /usr/local/bin/filebrowser -c /etc/filebrowser/default.json

Nov 21 09:12:33 filemanager systemd[1]: Started File browser: .
Nov 21 09:12:38 filemanager filebrowser[462]: 2022/11/21 09:12:38 Using config file: /etc/filebrowser/default.>
Nov 21 09:12:38 filemanager filebrowser[462]: 2022/11/21 09:12:38 Listening on [::]:8080
Nov 21 09:13:47 filemanager filebrowser[462]: 2022/11/21 09:13:47 /api/renew: 401 127.0.0.1 <nil>

Install and Configure Nginx

Install Nignx using the below command.

sudo apt install nginx

Remove default Nginx configuration.

sudo rm /etc/nginx/sites-available/default
sudo rm /etc/nginx/sites-enabled/default

Create new Nginx configuration

sudo nano /etc/nginx/sites-available/filebrowser.conf

We will use a subdomain to configure our file browser.

Paste the following

server {
     listen [::]:80;
     listen 80;

     server_name sub.domain.com;

     client_max_body_size 48M;

     location / {
         proxy_pass http://localhost:8080;
         proxy_http_version 1.1;
         proxy_set_header Upgrade $http_upgrade;
         proxy_set_header Connection 'upgrade';
         proxy_set_header Host $host;
         proxy_cache_bypass $http_upgrade;
    }
}

You can update the client_max_body_size 48M to whichever size you wish to have the upload size.

Save and exit the file.

Enable your configuration by creating a symbolic link

sudo ln -s /etc/nginx/sites-available/filebrowser.conf /etc/nginx/sites-enabled/filebrowser.conf

Check your Nginx configuration and restart Nginx

sudo nginx -t
sudo service nginx restart

Now you can visit your sub-domain name in browser, you should view the the login page.

These are the default login details.

user: admin
pass: admin
File Browser

Create SSL certificate and enable HTTP/2

HTTPS
HTTPS is a protocol for secure communication between a server (instance) and a client (web browser). Due to the introduction of Let’s Encrypt, which provides free SSL certificates, HTTPS are adopted by everyone and also provides trust to your audiences.

sudo apt install python3-certbot-nginx

Now we have installed Certbot by Let’s Encrypt for Ubuntu 22.04, run this command to receive your certificates.

sudo certbot --nginx --redirect --no-eff-email --agree-tos -m [email protected] -d sub.domain.com

Conclusion

Now you have learned how to install File Browser on Ubuntu 22.04 with Nginx reverse proxy.

Thanks for your time. If you face any problem or any feedback, please leave a comment below.

Cart

Your Cart is Empty

Back To Shop