Docker Project that I wanted to share

Hello community! Log time lurker here, so I decided to post on a recent project of mine.

I have a home lab server that I use mainly as a media server for my family and a few of my friends. It’s been a fantastic hobby and is certainly helping me learn as I grow in my role with a cybersecurity company.

But one use I wanted to get from my server was a way to easily access the files of the computer. Now before anyone says “NextCloud” or “OwnCloud” or any other cloud storage alternative, keep reading, as I had a different set of requirements.

My goal was not to create a dropbox like experience where I could access a store of information. My goal was to easily access the files of my server, including system files, config files, compose files, etc without having to ssh into the server. Here were my requirements:

  • Web accessible (I’m on a headless server)
  • Docker friendly
  • Access to the root of drive
  • Easily move, rename, copy, and delete files (even in system protected areas)
  • Clean, smooth interface
  • Multi-user support
  • Low system requirements
  • No complex database requirements

Ultimately, I landed on Filebrowser. Although ongoing support is minimal right now, as it stands, the product has been extremely stable for me. It’s very lightweight, written in Go, and checks off every requirement.

Filebrowser looks and feels like monochrome version of google drive. It supports drag and drop, file renaming, copying, moving, deleting, and even sharing. The sharing permissions can be set to expire or persist permanently. Really cool.

It has extra tools such as shell and an MD5 and SHA info. Very nice and convenient, if you need such tools.

Installing was very easy, but I didn’t do it exactly like they said in their documentation. On my linux box, I navigated to my docker apps folder and created a folder for filebrowser (to house the config files).

mkdir filebrowser cd filebrowser 

Then I made an empty database.db which contains the user database. You’ll need to persist this data, in case of a container restart or rebuild.

touch database.db 

Then I made a filebrowser.json file which contains the default settings for the app itself.

nano filebrowser.json 

and then put these settings in the file:

{ "port": 80, "baseURL": "", "address": "", "log": "stdout", "database": "/database.db", "root": "/files" } 

These are the default settings, except I renamed /srv to /files (personal preference).

Then all you need is to spin up the docker. I use docker-compose:

# Filebrowser filebrowser: container_name: filebrowser hostname: filebrowser restart: always image: filebrowser/filebrowser ports: - "5082:80" volumes: - /:/files - ${USERDIR}/docker/filebrowser/database.db:/database.db - ${USERDIR}/docker/filebrowser/filebrowser.json:/.filebrowser.json networks: - default - traefik_proxy labels: - "traefik.enable=true" - "traefik.backend=filebrowser" - "traefik.frontend.rule=Host:files.${DOMAINNAME}" - "traefik.port=80" - "traefik.docker.network=traefik_proxy" - "traefik.frontend.headers.SSLRedirect=true" - "traefik.frontend.headers.STSSeconds=315360000" - "traefik.frontend.headers.browserXSSFilter=true" - "traefik.frontend.headers.contentTypeNosniff=true" - "traefik.frontend.headers.forceSTSHeader=true" - "traefik.frontend.headers.SSLHost=${DOMAINNAME}" - "traefik.frontend.headers.STSIncludeSubdomains=true" - "traefik.frontend.headers.STSPreload=true" - "traefik.frontend.headers.frameDeny=true" 

I use Traefik for a reverse proxy, so if you dont use Traefik, just ignore the labels and declared networks.

Now I have a way to access my server files, even system files, from the web. Exactly what I wanted.

Bonus Round

I also wanted to host a "public" simple file server. This file server would only be files in a specific "DMZ" folder. To run this, I chose goStatic, a project by Pierre Zemb u/pierrezemb. It is extremely lightweight and is absolutely simple to use. Pierre has some really great features, such as basic auth, appending headers, etc. But I didn't need any of this, since the goal was to create a public file server where direct links could be used.

So here's my docker compose:

 publicserver: image: pierrezemb/gostatic container_name: publicserver restart: always ports: - "8043:8043" volumes: - /var/run/docker.sock:/var/run/docker.sock - /srv/vaultfs/rootfs/fileserver/public:/srv/http environment: - TZ=${TZ} networks: - traefik_proxy - default labels: - "traefik.enable=true" - "traefik.backend=public.files" - "traefik.frontend.rule=Host:public.files.${DOMAINNAME}" - "traefik.port=8043" - "traefik.docker.network=traefik_proxy" - "traefik.frontend.headers.SSLRedirect=true" - "traefik.frontend.headers.STSSeconds=315360000" - "traefik.frontend.headers.browserXSSFilter=true" - "traefik.frontend.headers.contentTypeNosniff=true" - "traefik.frontend.headers.forceSTSHeader=true" - "traefik.frontend.headers.SSLHost=${DOMAINNAME}" - "traefik.frontend.headers.STSIncludeSubdomains=true" - "traefik.frontend.headers.STSPreload=true" - "traefik.frontend.headers.frameDeny=true" 

Done. Now when I navigate to public.files.domain.com, I get a fast web server. I'm even thinking about hosting a simple site on there. If the root of the folder contains an index.html, the web page loads up immediately.

I'm very happy with how this project turned out. It took me a while to find the right components (I tried SO many web servers and web based file browsers). I hope you like this project. I loved it and just wanted to share it!

submitted by /u/jiru443
[link] [comments]
Source: Reddit