Static HTTP Server
Pico http server to serve static content only.
Features
- 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.)
Changelog
Version 2.0.2, 2021-11-03
- Add custom HTTP headers support
Version 2.0.1, 2021-11-02
- Add not_found redirect option
Version 2.0.0
- net/http was replaced with fasthttp
- prefix option was removed
Usage
Simple usage with an example index.html
$ docker run -p 127.0.0.1:8080:8080 --name test-static-http-server -d dshadow/static-http-server
Simple usage with a custom www folder
$ 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
Usage with docker-composer
- 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
Compile and use without containers
$ 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
Command line arguments
- -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")
Contributing
Fork -> Patch -> Push -> Pull Request
Authors
License
MIT
Copyright
Copyright (c) 2021 Kostiantyn Cherednichenko