Skip to content

Latest commit

History

History
121 lines (88 loc) · 2.31 KB

File metadata and controls

121 lines (88 loc) · 2.31 KB

simplehttpserver

A simple static file http server

Features

  • Supports multiple paths mapping
  • Supports angular router
  • Supports custom index files
  • Supports TLS (HTTPS)
  • Supports basic authorize
  • Supports compress
  • Supports log file and colorful output
  • Supports upload files

Run

Simple to run

Current file path mapping to web root, default port is 8080.

./simplehttpserver

Browse http://localhost:8080

Supports angular router

The dist path mapping to web root, port to 4200, index file is index.html and supports fallback to index.html

./simplehttpserver -addr :4200 -path dist -indexnames index.html -fallback index.html

Supports TLS

First, you can use mkcert to create the cert-files for develop.

mkcert -install
mkcert -cert-file ssl-cert.pem -key-file ssl-cert.key localhost 127.0.0.1 ::1

Then run command

./simplehttpserver -addrtls :8081 -certfile ssl-cert.pem -keyfile ssl-cert.key -username admin -password admin -logfile 1.log

Browse https://localhost:8081

Configuration file

  1. Make a config file

    ./simplehttpserver -makeconfig config.yaml
  2. Edit config.yaml

    You can add multiple paths in the config file.

    Line starts with # is a comment line.

    addr: 0.0.0.0:8080#addrtls: 0.0.0.0:8081#certfile: ./ssl-cert.pem#keyfile: ./ssl-cert.key#username: admin#password: admincompress: falsepaths:
    #/c: "C:\\"#/d: "D:\\"indexnames:
    - index.html
    - index.htmverbose: trueenablecolor: trueenableupload: true## maxrequestbodysize 0 to default sizemaxrequestbodysize: 9223372036854775807## timeout 0s is no limitreadtimeout: 0swritetimeout: 0slogfile: ./simplehttpserver.log#fallback: ./index.html#HTTP_PROXY:#HTTPS_PROXY:#NO_PROXY: ::1,127.0.0.1,localhost
  3. Run with the config file

    ./simplehttpserver -config config.yaml

Get help

./simplehttpserver -help

Build

bash ./build.sh

Thanks

Powered by