static-http-server

command module
v0.0.0-...-175f8c1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 3, 2021 License: MIT Imports: 4 Imported by: 0

README

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 (c) 2021 Kostiantyn Cherednichenko

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL