Skip to content
This repository has been archived by the owner on Mar 23, 2020. It is now read-only.

m2nlight/simplehttpserver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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: admin
    compress: false
    paths:
      #/c: "C:\\"
      #/d: "D:\\"
    indexnames:
      - index.html
      - index.htm
    verbose: true
    enablecolor: true
    enableupload: true
    ## maxrequestbodysize 0 to default size
    maxrequestbodysize: 9223372036854775807
    ## timeout 0s is no limit
    readtimeout: 0s
    writetimeout: 0s
    logfile: ./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

About

A simple static file http server

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published