Pico http server to serve static content only.
- Fast and small! It's only 4.35MB !!!
- Based on github.com/valyala/fasthttp + scratch container
- Designed for Docker Compose and Kubernetes (but can be used in other env.)
- Add custom HTTP headers support
- Add not_found redirect option
- net/http was replaced with fasthttp
- prefix option was removed
$ docker run -p 127.0.0.1:8080:8080 --name test-static-http-server -d dshadow/static-http-server
$ docker run -p 127.0.0.1:8080:8080 --name test-static-http-server -v /my/custom/www/folder:/www -d dshadow/static-http-server
- Create custom docker-compose.yml
version: '3.8'
services:
web:
image: dshadow/static-http-server
expose:
- 8080:8080
volumes:
- /my/custom/www/folder:/www
- Replace /my/custom/www/folder with your own static folder
- Build and run
$ docker-compose up --build -d
- Stop and remove
$ docker-compose down
$ git clone https://github.com/dshadow/static-http-server.git
$ go build -o shs shs.go
$ ./shs -l :8080 -p /example/images -s /var/share/www
- -h Show help and exit
- -l Listening on all interfaces with a specified tcp port (default value: ":3000")
- -c Enable compression
- -s Static folder with index.html and other files (default value: "/www")
- -r Redirect path if not found (example: /index.html), except: favicon.ico, robots.txt
- -H Add custom HTTP headers (example: -H "Access-Control-Allow-Origin: *" -H "X-Content-Type-Options: nosniff")
Fork -> Patch -> Push -> Pull Request
MIT
Copyright (c) 2021 Kostiantyn Cherednichenko