Skip to content

dshadow/static-http-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Static HTTP Server

Docker Size GitHub Repo

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

  1. Create custom docker-compose.yml
version: '3.8'
services:
  web:
    image: dshadow/static-http-server
    expose:
      - 8080:8080
    volumes:
	  - /my/custom/www/folder:/www
  1. Replace /my/custom/www/folder with your own static folder
  2. Build and run
$ docker-compose up --build -d
  1. 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

About

Pico http server to serve static content only

Resources

License

Stars

Watchers

Forks

Packages

No packages published