Install File Browser and adding SSL

As root execute the following.

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

That’s it for installation!

Testing filebrowser

  • filebrowser -p 8080 -a 134.122.27.34 -r /path/to/your/files

-p is the port to listen on
-a is the IP address to listen on
-r is the root directory that you’d like to serve. In most cases on Unix, this is /var/www/html/

In a web browser, you can go to your IP address or domain name with the port that you specified. The default credentials are as follows.

Username: admin
Password: admin

AUTO START ON REST

Since the database is automatically created for us, let’s create a file in the /etc/ directory called filebrowser.json

Please update the configuration file with values that are appropriate for your system.

{
“port”: 8080,
“baseURL”: “”,
“address”: “134.122.27.34”,
“log”: “stdout”,
“database”: “/etc/filebrowser.db”,
“root”: “/var/www/”
}

Now execute this command to activate filebrowser….

  • filebrowser -c /etc/filebrowser.json

How to Run filebrowser on Boot

Let’s make a system daemon to startup filebrowser when the system starts up. These instructions were written with an Ubuntu operating systems in mind.

Create the following file at /etc/systemd/system/filebrowser.service

[Unit]

Description=File Browser

After=network.target

[Service]

ExecStart=/usr/local/bin/filebrowser -c /etc/filebrowser.json

[Install]

WantedBy=multi-user.target

To enable and start the filebrowser service, run the following commands.

  • systemctl enable filebrowser.service
  • systemctl start filebrowser.service

How to Install an SSL Certificate for filebrowser

This can be a little fiddly.

You will need a Domain and in the A in records point it to a Public IP address, set up the port forwarding from port 80 to the internal IP port 80 (this is just for now)

Install a web server

  • apt install apache2

install Certbot

Step 1 – Installing Certbot

Certbot is a tool to obtain certificates from Let’s Encrypt and configure on your web server. Snap package is the easist way for installing certbot on Ubuntu system.

You might have to run this first…

  • sudo apt update
  • sudo apt install snapd
  • sudo snap install snap-store
  • sudo snap install –classic certbot

if you get an error you can try

  • sudo apt install fuse squashfuse

NOTE: Snaps rely on certain Linux kernel features which are not available under containerized servers like those running under openvz, so if you get an error use,

  • sudo apt install certbot

when installed 

  • certbot certonly –apache -d your_domain_name

when installed copy the following…

 

 

Congratulations! Your certificate and chain have been saved at:

   /etc/letsencrypt/live/drive.itsnotgoogle.com/fullchain.pem

   Your key file has been saved at:

   /etc/letsencrypt/live/drive.itsnotgoogle.com/privkey.pem

   Your certificate will expire on 2022-10-13. To obtain a new or

   tweaked version of this certificate in the future, simply run

   certbot again. To non-interactively renew *all* of your

   certificates, run “certbot renew”

now add them to the filebrowser.json

  • cd etc
  • nano filebrowser.json

“port”: 8080,
“baseURL”: “”,
“address”: “192.168.0.63”,
“log”: “stdout”,
“database”: “/etc/filebrowser.db”,
“root”: “/var/www/”,
“cert”: “/etc/letsencrypt/live/drive.itsnotgoogle.com/fullchain.pem”,
“key”: “/etc/letsencrypt/live/drive.itsnotgoogle.com/privkey.pem”

  • systemctl restart filebrowser.service
  • systemctl status filebrowser.service

Now change the port forwarding to

port 443 & port 8080

port 443 is use by the web browser for SSL.

Certbot not installing ssl certificate with “sudo certbot renew”

If Certbot fails when using “sudo certbot renew”

And you get this….

To fix these errors, please make sure that your domain name was
entered correctly and the DNS A/AAAA record(s) for that domain
contain(s) the right IP address. Additionally, please check that
your computer has a publicly routable IP address and that no
firewalls are preventing the server from communicating with the
client. If you’re using the webroot plugin, you should also verify
that you are serving files from the webroot path you provided.

Try make the changes to your Apache configuration by hand, and run this command.

sudo certbot certonly --apache

This has work for us 99% of the time.