Sign inSign up

marcelndev/static-file-server

By marcelndev

•Updated almost 2 years ago

Static file server that uses environment variables for configuration

Image
Web servers
0

524

marcelndev/static-file-server repository overview

⁠Static File Server

⁠

⁠Introduction

Static file server that uses environment variables for configuration. The file server is available as a container image here: https://hub.docker.com/r/marcelndev/static-file-server⁠.

⁠⚠️ Important

The file server in its current form is not meant to be used as an edge (internet-facing) web server. A reverse proxy should be used to support HTTPS for example. Some reverse proxies that can be used: Apache, Caddy, IIS, Nginx, YARP

⁠Configuration

The following environment variables are supported to configure the file server:

Environment variableDefault valueDescription
SFS_PORT80Must be a valid port number.
SFS_DEBUGfalseEnable debugging for troubleshooting.
If set to true this prints detailed information about each request (and its response) to stdout.
SFS_ALLOW_INDEXtrueWhen set to true the index.html file in the folder will be served.
SFS_SHOW_LISTINGtrueServes the directory listing when set to true.
If ALLOW_INDEX is also true no listing will be shown when an index.html file exists in the directory.
SFS_FALLBACK_TO_INDEXfalseWhen set to true the root index.html file will be served in case a non-existent path is requested.
This is relevant when serving single-page applications.

⁠Deployment

⁠Using a folder on the host machine

The following command serves the contents of the folder "/some/folder/on/host" over http://localhost:8080⁠.

docker run -p 8080:80 -v /some/folder/on/host:/wwwroot marcelndev/static-file-server:latest

You can provide environment variables like so:

docker run \
    -p 8080:5000 \
    -v /some/folder/on/host:/wwwroot \
    -e SFS_PORT=5000 \
    -e SFS_SHOW_LISTING=false \
    -e SFS_FALLBACK_TO_INDEX=true \
    marcelndev/static-file-server:latest
⁠Dockerfile

This options creates a new image that includes the contents that need to be served.

FROM marcelndev/static-file-server:latest
COPY /some/folder/on/host /wwwroot

When you want to run this custom image you can omit the volume mapping (-v argument).

Tag summary

Content type

Image

Digest

sha256:be632c84d…

Size

3.8 MB

Last updated

almost 2 years ago

docker pull marcelndev/static-file-server