Rust-Simple http server 0.6.0: simple-http-server — simple static http server

icon
Latest Release: 0.6.0

How it looks like?

Screenshot

Command Line Arguments

Simple HTTP(s) Server 0.6.0

USAGE:
    simple-http-server [FLAGS] [OPTIONS] [--] [root]

FLAGS:
        --cors       Enable CORS via the "Access-Control-Allow-Origin" header
    -h, --help       Prints help information
    -i, --index      Enable automatic render index page [index.html, index.htm]
        --nocache    Disable http cache
        --norange    Disable header::Range support (partial request)
        --nosort     Disable directory entries sort (by: name, modified, size)
    -s, --silent     Disable all outputs
    -u, --upload     Enable upload files (multiple select)
    -V, --version    Prints version information

OPTIONS:
    -a, --auth <auth>                              HTTP Basic Auth (username:password)
        --cert <cert>                              TLS/SSL certificate (pkcs#12 format)
        --certpass <certpass>                      TLS/SSL certificate password
    -c, --compress <compress>...
            Enable file compression: gzip/deflate
                Example: -c=js,d.ts
                Note: disabled on partial request!
        --ip <ip>                                  IP address to bind [default: 0.0.0.0]
    -p, --port <port>                              Port number [default: 8000]
        --redirect <redirect>                      takes a URL to redirect to using HTTP 301 Moved Permanently
    -t, --threads <threads>                        How many worker threads [default: 3]
        --try-file <PATH>
            serve this file (server root relative) in place of missing files (useful for single page apps) [aliases:
            try-file-404]
    -l, --upload-size-limit <upload_size_limit>    Upload file size limit [bytes] [default: 8000000]


Installation

Download binary

Goto Download

  • windows-64bit
  • osx-64bit
  • linux-64bit

Install by cargo

# Install Rust
curl https://sh.rustup.rs -sSf | sh

# Install simple-http-server
cargo install simple-http-server
rehash
simple-http-server -h

Features

  • Windows support (with colored log)
  • Specify listen address (ip, port)
  • Specify running threads
  • Specify root directory
  • Pretty log
  • Nginx like directory view (directory entries, link, filesize, modfiled date)
  • Breadcrumb navigation
  • (default enabled) Guess mime type
  • (default enabled) HTTP cache control
    • Sending Last-Modified / ETag
    • Replying 304 to If-Modified-Since
  • (default enabled) Partial request
    • Accept-Ranges: bytes([ByteRangeSpec; length=1])
    • [Range, If-Range, If-Match] => [Content-Range, 206, 416]
  • (default disabled) Automatic render index page [index.html, index.htm]
  • (default disabled) Upload file
  • (default disabled) HTTP Basic Authentication (by username:password)
  • Sort by: filename, filesize, modifled
  • HTTPS support
  • Content-Encoding: gzip/deflate
  • Added CORS headers support
  • Silent mode

Comments

  • Preview document  could messy code
    Preview document could messy code

    Apr 8, 2021

    Can open file with utf-8 ?

    Reply
  • ? Potential Security Vulnerability
    ? Potential Security Vulnerability

    Jun 1, 2021

    Hello, @TheWaWaR @vi @not-fl3 @michelk @tforgione - 2 potential high severity security vulnerability in your repository has been disclosed to huntr.

    Visit report URL and validate them https://www.huntr.dev/bounties/3-other-TheWaWaR/simple-http-server/ https://www.huntr.dev/bounties/2-other-TheWaWaR/simple-http-server/

    Best Regards

    Reply
  • Trying to get in touch regarding a security issue
    Trying to get in touch regarding a security issue

    Jul 15, 2021

    Hi there,

    I couldn't find a SECURITY.md in your repository and am not sure how to best contact you privately to disclose a security issue.

    Can you add a SECURITY.md file with an e-mail to your repository, so that our system can send you the vulnerability details? GitHub suggests that a security policy is the best way to make sure security issues are responsibly disclosed.

    Once you've done that, you should receive an e-mail within the next hour with more info.

    Thanks! (cc @huntr-helper)

    Reply
  • Update SECURITY.md
    Update SECURITY.md

    Jul 26, 2021

    Thank you kindly for creating a security policy. However, there were no instructions for getting in touch. Kindly provide an email in the SECURITY.md so that security researchers may know how to reach you regarding vulnerabilities in your repo. Thanks!

    Reply
  • support watch mode and hot reload for html and css
    support watch mode and hot reload for html and css

    Sep 10, 2021

    null

                                                                                                                                                                                                           
    Reply
  • certificates generated by mkcert cause `mac verify failure`
    certificates generated by mkcert cause `mac verify failure`

    Oct 8, 2021

    I'm attempting to use simple-http-server with mkcert to create valid certs for local development. I'm generating a P12 cert with mkcert, but simple-http-server rejects it with mac verify failure.

    Here's a recording of the process:

    https://asciinema.org/a/tFAgoaVnHB1j9OsdG4YiIZJvq

    I'd guess this isn't simple-http-server's issue, just reporting it in case there's a known fix, or if anyone can point me to the library that's emitting the error (hyper?).

    Reply
  • Added silent option
    Added silent option

    Jun 7, 2018

    Hi!

    Thanks for this nice server ! I used to use node's http-server but I wasn't really satisfied with it. However, it has a silent option, that disables all outputs.

    This pull requests adds this feature. I didn't disable the error message, because I think it would not be user friendly if the program failed silently.

    Reply
  • Question: How to use --cert option ?
    Question: How to use --cert option ?

    Oct 14, 2020

    There is not instructions in the repository, and all method that I have tried failed with random error messages: such as: Tls(Error { code: -25264, message: "MAC verification failed during PKCS12 import (wrong password?)" })'

    methods: https://gist.github.com/Eng-Fouad/6cdc8263068700ade87e4e3bf459a988 https://gist.github.com/princeppy/d00bad66d9caac86d9b7d3ce9e35fc12

    Is it possible to add somewhere how such desired pkcs12 file could be generated ?

    Reply
  • Version from cargo and released bin is unsecure!
    Version from cargo and released bin is unsecure!

    Apr 13, 2020

    http://x.x.x.x/%2F is possible! No problem to retrieve ro-files from /etc.

    Also would be nyce to see a https-only and an autogenration for self-signed certs.

    Reply
  • Please support serve specified file for not found path (useful for single page apps)
    Please support serve specified file for not found path (useful for single page apps)

    Mar 15, 2018

    Like the --entry-file parameter of live-server.

    Reply
  • [feature] add mime type bindings by command line
    [feature] add mime type bindings by command line

    Oct 2, 2018

    While experimenting with WebAssembly I found that (at least in Firefox) WebAssembly.instantiateStreaming() requires .wasm-resources to be delivered as application/wasm. Otherwise you end up with "TypeError: Response has unsupported MIME type".

    Since application/wasm doesn't seem to be official, yet (https://www.iana.org/assignments/media-types/media-types.xhtml#application) I cannot expect simple-http-server to include this binding.

    It would be helpful to be able to add bindings between file extensions and mime types via command line.

    Reply
  • Sensitive information disclosure
    Sensitive information disclosure

    May 18, 2018

    Readable to /etc/passwd file http://your-ip/..%2f..%2f..%2f..%2f..%2f..%2f..%2f..%2f..%2f..%2f..%2f..%2fetc/passwd

    Reply