Samba & SMB Web Access Through Filestash With Passthrough Auth

This article explains how to set up Filestash in a Docker container as a web interface for browser-based access to a Samba or SMB file server.

Please note that in my own use this configuration has been superseded by Sambee, my very own browser-based file viewer and manager. Sambee has a more polished and user-friendly UI, is optimized for desktop and mobile, displays Markdown not as code but rendered, has powerful search and navigation capabilities, keyboard shortcuts, and much more.

This article is part of a mini-series about running Samba Active Directory and a file server service in a Docker container on a home server:

Filestash Installation

Preparation

I’m assuming that you’ve set up Docker, the Caddy container and a Samba file server as described in previous articles.

Dockerized Filestash Directory Structure

This is what the directory structure will look like when we’re done:

rpool/
 └── encrypted/
     └── docker/
         └── filestash/
             ├── data/
             ├── container-vars.env
			 └── docker-compose.yml

We’re placing the configuration on the encrypted ZFS dataset (rpool/encrypted).

Create the new directories and set ownership of the directories to user/group ID 1000, which are used by the dockerized application:

mkdir -p /rpool/encrypted/docker/filestash/data
chown -Rfv 1000:1000 /rpool/encrypted/docker/filestash/data

Filestash Docker Compose File

Create docker-compose.yml with the following content:

services:

  filestash:
    container_name: filestash
    hostname: filestash
    image: machines/filestash:latest
    restart: unless-stopped
    networks:
      caddy_caddynet:
    expose:
      - 8334                                      # Web UI
    env_file:
      - container-vars.env
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - ./data:/app/data/state

networks:
  caddy_caddynet:
    external: true

Environment Variable File container-vars.env

Create the file container-vars.env with the following content:

# External FQDN without http(s)://
# See https://github.com/mickael-kerjean/filestash/issues/828
APPLICATION_URL=files.home.yourdomain.com    # replace with your domain

Start the Filestash Container

Navigate into the directory with docker-compose.yml and run:

docker compose up -d

Inspect the container logs for errors with the command docker compose logs --tail 30 --timestamps.

Let’s Encrypt Certificate for Filestash via Caddy

Caddyfile

Add the following to Caddyfile (details):

files.{$MY_DOMAIN} {
	reverse_proxy filestash:8334 {
	}
	tls {
		dns cloudflare {env.CLOUDFLARE_API_TOKEN}
	}
}

DNS A Record

Add the following A record to your DNS domain:

files.home.yourdomain.com 192.168.0.4     # replace with your Docker host's IP address

Try to resolve the name on a machine in your network (e.g., nslookup files.home.yourdomain.com).

Reload Caddy’s Configuration

Instruct Caddy to reload its configuration by running:

docker exec -w /etc/caddy caddy caddy reload

You should now be able to access the Filestash web interface at https://files.home.yourdomain.com without getting a certificate warning from your browser.

Initial Filestash Configuration

Open the web UI in your browser and set your admin password. You should see a message telling you that SSL is configured properly. You’re now on the admin page at https://files.home.yourdomain.com/admin/backend.

Select Settings and disable the following:

  • API
  • Share
  • Chromecast
  • Video transcoder

Select Logs and disable the logging functionality (there might be a bug causing the log to grow indefinitely).

Configure Samba File Share as Backend

Select Backend > Storage Backend > Samba, select Authentication middleware > Passthrough and configure the following:

  • Passthrough strategy: username_and_password
  • Attribute mapping:
    • Hostname: fs1.ad.internal (hostname of your Samba file server)
    • Username: {{ .user }}
    • Password: {{ .password }}
    • Path: /Data (repeat your share name here)
    • Port: 445
    • Domain: AD (your Active Directory domain name)
    • Share name: Data (or your alternative share name)

Test Samba File Access

Open the user UI URL https://files.home.yourdomain.com. You should see a simple username/password text input fields. Enter your Samba file share credentials and click connect. You’re now accessing your SMB file share via your browser. Uploading, downloading, and editing should all work, in addition to preview in the browser, of course.

Comments

Related Posts

Samba File Server: Web Access Through Filebrowser With SSO & HTTPS

Samba File Server: Web Access Through Filebrowser With SSO & HTTPS
This article explains how to set up Filebrowser in a Docker container as a web interface for browser-based access to a Samba file server. Please note that in my own use this configuration has been superseded by Sambee, my very own browser-based file viewer and manager. Sambee is much more secure and flexible in that it accesses the file system via SMB as the actual authenticated user. This makes it possible to access multiple shares on different file servers with Sambee, adhere to the share and file system permissions configured for each user account, and audit changes properly.
Home Automation, Networking & Self-Hosting

Latest Posts

Filebrowser to Be Archived. Migrate to a Modern Alternative: Sambee

Filebrowser to Be Archived. Migrate to a Modern Alternative: Sambee
Filebrowser is being archived. As the author writes, the codebase dates back to when he was but 15 years old. Having created such a popular file management tool is a more than impressive achievement for anyone, let alone a teenager. However, when it comes to security and reliability, Filebrowser seems to be built on a less than ideal foundation, so much so that the author states:
Home Automation, Networking & Self-Hosting