Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: http-party/http-server
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: d5b599f2932a6dd96e4c0efc87edfb8c139c5832
Choose a base ref
...
head repository: http-party/http-server
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 77243e7a824a85b2ae0773b7a05fa24d41db2ce5
Choose a head ref

Commits on Feb 26, 2016

  1. delete redundant "//"

    sqlwwx committed Feb 26, 2016
    Copy the full SHA
    c32ebc3 View commit details
  2. fixbug with -o [path]

    sqlwwx committed Feb 26, 2016
    Copy the full SHA
    29183e9 View commit details
  3. format

    sqlwwx committed Feb 26, 2016
    Copy the full SHA
    fb00da5 View commit details

Commits on Jul 24, 2016

  1. -t flag to control timeout

    julien-f committed Jul 24, 2016
    Copy the full SHA
    2dcb4bb View commit details

Commits on Nov 6, 2016

  1. Aggressively turn off caching when cache time set to -1

    Edward D'Souza committed Nov 6, 2016
    Copy the full SHA
    01742b5 View commit details
  2. Fix style: use single quotes for string.

    Edward D'Souza committed Nov 6, 2016
    Copy the full SHA
    541ab5d View commit details
  3. Fix style: don't use hanging indent for closing bracket.

    Edward D'Souza committed Nov 6, 2016
    Copy the full SHA
    f1f14fa View commit details

Commits on May 22, 2017

  1. Update Node.js versions to latest list (> 4)

    Remove old notification and allow_failures settings
    BigBlueHat committed May 22, 2017
    Copy the full SHA
    37f2dae View commit details
  2. Remove npm install npm line

    Travis provides this out of the box
    BigBlueHat committed May 22, 2017
    Copy the full SHA
    9623164 View commit details

Commits on Jan 6, 2018

  1. Add HTTP Basic Auth

    Using https://www.npmjs.com/package/basic-auth
    
    Inspired and built on the work of jondlm in
    #51
    Kay Lovelace authored and neoeno committed Jan 6, 2018
    Copy the full SHA
    5113a57 View commit details
  2. Add Basic Auth configuration with env varaible

    Kay Lovelace authored and neoeno committed Jan 6, 2018
    Copy the full SHA
    b8101bd View commit details
  3. Use secure comparison for Basic Auth credentials

    Note that the order of arguments to secureCompare
    will have an effect upon the running time — though
    not in a way that leaks information about whether
    the passwords match.
    
    These:
    
    ```javascript
    compare("short", "short");
    compare("short", "loooo<...>ng");
    ```
    
    Will run faster than these:
    
    ```javascript
    compare("loooo<...>ng", "short");
    compare("loooo<...>ng", "loooo<...>ng");
    ```
    
    If someone could duplicate your exact set-up, they
    could possibly discover how long your secret
    password is by testing how long yours takes to run
    compared to how long their identical server takes
    to run given passwords of a known length.
    
    Given that this isn't the US Govt (I hope), it's
    not a huge concern, and I don't know enough to do
    it better. However, given that `http-server`
    typically runs on its own (without any other
    software that would 'pad out' the timing), you
    might want to consider and mitigate this vector of
    attack.
    Kay Lovelace authored and neoeno committed Jan 6, 2018
    Copy the full SHA
    45add9c View commit details

Commits on Jan 10, 2018

  1. Add README note to promote -c-1 usage

    Fixes #407 as best we can at this point without
    breaking existing deployments.
    BigBlueHat committed Jan 10, 2018
    Copy the full SHA
    b9b95b2 View commit details

Commits on Jan 23, 2018

  1. Optimize rasters

    mathieu-aubin authored and BigBlueHat committed Jan 23, 2018
    Copy the full SHA
    64428b7 View commit details

Commits on May 7, 2018

  1. Copy the full SHA
    9571d0a View commit details

Commits on May 31, 2018

  1. added url option to -0

    intotecho authored May 31, 2018
    Copy the full SHA
    214bf79 View commit details

Commits on Jun 15, 2018

  1. Update README for cli switch value clarity

    Booleans current MUST be lowercase.
    Improved Markdown for presenting cli values.
    BigBlueHat committed Jun 15, 2018
    Copy the full SHA
    9432968 View commit details

Commits on Jul 14, 2018

  1. Copy the full SHA
    d328f58 View commit details

Commits on Aug 8, 2018

  1. Add npm package-lock (#403)

    thornjad authored and BigBlueHat committed Aug 8, 2018
    Copy the full SHA
    b1b266c View commit details

Commits on Sep 3, 2018

  1. Add support for brotli encoding

    fixes #445
    thornjad committed Sep 3, 2018
    Copy the full SHA
    7f013c1 View commit details

Commits on Oct 4, 2018

  1. Add --port alias for -p flag (#468)

    * Feat: added --port flag
    
    * Docs: added --port flag to README.md
    
    Fixes #466
    Matt Johnston authored and BigBlueHat committed Oct 4, 2018
    Copy the full SHA
    e50fc44 View commit details

Commits on Dec 12, 2018

  1. add compression tests

    Jade Thornton committed Dec 12, 2018
    Copy the full SHA
    40357dd View commit details
  2. add compression test files

    Jade Thornton committed Dec 12, 2018
    Copy the full SHA
    2cee0a3 View commit details

Commits on Dec 13, 2018

  1. fix tests so they do what they say they do

    Jade Thornton committed Dec 13, 2018
    Copy the full SHA
    8a3b87e View commit details

Commits on Jan 23, 2019

  1. Handle proxy errors

    nLight committed Jan 23, 2019
    Copy the full SHA
    0b69655 View commit details

Commits on Jan 25, 2019

  1. Point out the npx option (#488)

    wmertens authored and BigBlueHat committed Jan 25, 2019
    Copy the full SHA
    7564021 View commit details

Commits on Feb 3, 2019

  1. Update license year

    Signed-off-by: Jade Thornton <jade@jmthornton.net>
    thornjad committed Feb 3, 2019
    Copy the full SHA
    8b5b565 View commit details

Commits on Feb 4, 2019

  1. add option for client IP logging

    Continuing work by @paked in #187, this adds the useful feature of
    logging the remote client IP address. I personally use this feature in
    Apache often at work, and it would be nice to have it here as well!
    
    The addition is the `--log-ip` option, which adds the client IP to the
    log message between the date and the request method and url.
    
    Signed-off-by: Jade Thornton <jade@jmthornton.net>
    thornjad committed Feb 4, 2019
    Copy the full SHA
    51cdf57 View commit details
  2. use quotes to check switch

    Signed-off-by: Jade Thornton <jade@jmthornton.net>
    thornjad committed Feb 4, 2019
    Copy the full SHA
    bfee8d4 View commit details

Commits on Feb 5, 2019

  1. Copy the full SHA
    64de7f5 View commit details

Commits on Feb 6, 2019

  1. Merge pull request #503 from amad-person/add-issue-pr-templates

    Add issue and pull request templates
    thornjad authored Feb 6, 2019
    Copy the full SHA
    74ba105 View commit details

Commits on Feb 7, 2019

  1. Updated dependencies to fix security issues

    Removed common-style (deprecated, depends on unpatched packages)
    
    Issue #461
    chill117 committed Feb 7, 2019
    Copy the full SHA
    72d7614 View commit details

Commits on Feb 11, 2019

  1. Copy the full SHA
    004da3b View commit details

Commits on Apr 6, 2019

  1. Copy the full SHA
    3e9a57f View commit details

Commits on Apr 15, 2019

  1. Merge pull request #499

    Update license year
    thornjad committed Apr 15, 2019
    Copy the full SHA
    9310c41 View commit details
  2. Merge pull request #501

    add option for client IP logging
    thornjad committed Apr 15, 2019
    Copy the full SHA
    c68ff7f View commit details
  3. add thornjad to contributors

    thornjad committed Apr 15, 2019
    Copy the full SHA
    2b11028 View commit details
  4. 1
    Copy the full SHA
    34467ea View commit details
  5. Merge pull request #452 from IamfromSpace:preve...

    ...nt-vows-error-swallowing
    
    Prevent vows from swallowing test errors on uncaught errors within
    topics
    thornjad committed Apr 15, 2019
    Copy the full SHA
    573fe58 View commit details
  6. Merge pull request #326 from ghedsouza:really-t...

    ...urn-off-caching-when-cache-set-to-negative-one
    
    Aggressively turn off caching when cache time set to -1
    thornjad committed Apr 15, 2019
    Copy the full SHA
    8bc2fe0 View commit details
  7. Merge pull request #485 from chill117/update-de...

    ...ps-to-fix-security-issues
    
    Updated dependencies to fix security issues
    thornjad committed Apr 15, 2019
    Copy the full SHA
    68b48eb View commit details
  8. Copy the full SHA
    ec08b63 View commit details
  9. Merge pull request #245 from neoeno/master

    Add HTTP Basic Auth
    thornjad committed Apr 15, 2019
    Copy the full SHA
    456f7ff View commit details
  10. add basic auth pkgs to lock

    relates to #245
    thornjad committed Apr 15, 2019
    Copy the full SHA
    597c126 View commit details
  11. Merge pull request #477 from dcos-labs/add-prox...

    ...y-error-handling
    
    Handle proxy errors
    
    Fixes #193
    thornjad committed Apr 15, 2019
    Copy the full SHA
    e703c5b View commit details
  12. Copy the full SHA
    e1f5d23 View commit details
  13. Merge pull request #463 from thornjad/brotli-en...

    ...coding
    
    Add support for brotli encoding
    thornjad committed Apr 15, 2019
    Copy the full SHA
    3ccddaa View commit details
  14. Merge pull request #250 from wwx-node/master

    fixbug with -o [path] Open browser window after starting the server
    thornjad committed Apr 15, 2019
    Copy the full SHA
    c8e2cbb View commit details
  15. fix up wording

    thornjad committed Apr 15, 2019
    Copy the full SHA
    2e97199 View commit details
  16. standardize with bin

    thornjad committed Apr 15, 2019
    Copy the full SHA
    d8d001d View commit details
Showing with 18,176 additions and 245 deletions.
  1. +16 −0 .github/ISSUE_TEMPLATE
  2. +19 −0 .github/PULL_REQUEST_TEMPLATE
  3. +31 −0 .github/workflows/node.js.yml
  4. +5 −2 .gitignore
  5. +0 −13 .travis.yml
  6. +1 −1 LICENSE
  7. +92 −19 README.md
  8. +13 −0 SECURITY.md
  9. +65 −22 bin/http-server
  10. +160 −0 doc/http-server.1
  11. +34 −0 lib/core/aliases.json
  12. +18 −0 lib/core/defaults.json
  13. +9 −0 lib/core/etag.js
  14. +447 −0 lib/core/index.js
  15. +203 −0 lib/core/opts.js
  16. +65 −0 lib/core/show-dir/icons.json
  17. +171 −0 lib/core/show-dir/index.js
  18. +21 −0 lib/core/show-dir/perms-to-string.js
  19. +30 −0 lib/core/show-dir/size-to-string.js
  20. +36 −0 lib/core/show-dir/sort-files.js
  21. +20 −0 lib/core/show-dir/styles.js
  22. +96 −0 lib/core/status-handlers.js
  23. +57 −12 lib/http-server.js
  24. +14,151 −0 package-lock.json
  25. +44 −18 package.json
  26. BIN public/img/turtle.png
  27. BIN screenshots/directory.png
  28. BIN screenshots/public.png
  29. BIN screenshots/start.png
  30. +231 −0 test/304.test.js
  31. +66 −0 test/accept-encoding.test.js
  32. +126 −0 test/cache.test.js
  33. +17 −0 test/check-headers.js
  34. +124 −0 test/cli.test.js
  35. +187 −0 test/compression.test.js
  36. +52 −0 test/content-type.test.js
  37. +72 −0 test/core-error.test.js
  38. +74 −0 test/core.test.js
  39. +31 −0 test/custom-content-type-file-secret.test.js
  40. +47 −0 test/custom-content-type-file.test.js
  41. +33 −0 test/custom-content-type.test.js
  42. +22 −0 test/default-default-ext.test.js
  43. +20 −0 test/enotdir.test.js
  44. +21 −0 test/escaping.test.js
  45. +74 −0 test/express-error.test.js
  46. +76 −0 test/express.test.js
  47. +15 −0 test/fixtures/common-cases-error.js
  48. +160 −0 test/fixtures/common-cases.js
  49. +3 −0 test/fixtures/custom_mime_type.types
  50. +1 −0 test/fixtures/root/compression/index.html
  51. +3 −0 test/fixtures/root/compression/index.html.br
  52. BIN test/fixtures/root/compression/index.html.gz
  53. +4 −0 test/fixtures/root/htmlButNot
  54. +86 −0 test/headers.test.js
  55. +0 −158 test/http-server-test.js
  56. +26 −0 test/illegal-access-date.test.js
  57. +286 −0 test/main.test.js
  58. +20 −0 test/malformed-dir.test.js
  59. +21 −0 test/malformed.test.js
  60. +46 −0 test/mime.test.js
  61. +64 −0 test/process-env-port.test.js
  62. +1 −0 test/public/404.html
  63. BIN test/public/404.html.gz
  64. +1 −0 test/public/a.txt
  65. +1 −0 test/public/another-subdir/scripts.js
  66. +1 −0 test/public/b.txt
  67. +1 −0 test/public/brotli/fake_ecstatic
  68. BIN test/public/brotli/fake_ecstatic.br
  69. +1 −0 test/public/brotli/index.html
  70. +3 −0 test/public/brotli/index.html.br
  71. BIN test/public/brotli/index.html.gz
  72. +1 −0 test/public/brotli/not_actually_brotli.br
  73. +1 −0 test/public/brotli/real_ecstatic
  74. +2 −0 test/public/brotli/real_ecstatic.br
  75. +1 −0 test/public/c.js
  76. +1 −0 test/public/compress/foo.js
  77. BIN test/public/compress/foo.js.gz
  78. +1 −0 test/public/compress/foo_2.js
  79. +1 −0 test/public/curimit@gmail.com (40%)/index.html
  80. +13 −0 test/public/custom_mime_type.opml
  81. +3 −0 test/public/custom_mime_type.types
  82. +1 −0 test/public/d.js
  83. +1 −0 test/public/e.js
  84. +1 −0 test/public/f_f
  85. +1 −0 test/public/gzip/fake_ecstatic
  86. 0 test/public/gzip/fake_ecstatic.gz
  87. +1 −0 test/public/gzip/index.html
  88. BIN test/public/gzip/index.html.gz
  89. +1 −0 test/public/gzip/real_ecstatic
  90. BIN test/public/gzip/real_ecstatic.gz
  91. +4 −0 test/public/show-dir$$href_encoding$$/aname+aplus.txt
  92. +1 −0 test/public/subdir/app.wasm
  93. +1 −0 test/public/subdir/e.html
  94. +1 −0 test/public/subdir/index.html
  95. +1 −0 test/public/subdir_with space/file_with space.html
  96. +1 −0 test/public/subdir_with space/index.html
  97. +1 −0 test/public/中文/檔案.html
  98. +131 −0 test/range.test.js
  99. +34 −0 test/showdir-href-encoding.test.js
  100. +55 −0 test/showdir-pathname-encoding.test.js
  101. +35 −0 test/showdir-search-encoding.test.js
  102. +34 −0 test/showdir-with-spaces.test.js
  103. +26 −0 test/trailing-slash.test.js
16 changes: 16 additions & 0 deletions .github/ISSUE_TEMPLATE
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
**Steps to reproduce the issue, if applicable. Include the actual command and output and/or stack trace.**

<!-- Paste the command here: -->

**What did you expect to happen?**

<!-- Paste the error and / or stack trace here: -->

**If the issue is a feature request, what is the motivation / use case for it?**

**Tell us about your environment**
- **exact http-server version:**
- **Node version:**
- **Platform:**

**Other information (related issues, suggestions for a fix, etc):**
19 changes: 19 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
**Please ensure that your pull request fulfills these requirements:**
- [ ] The pull request is being made against the `master` branch
- [ ] Tests for the changes have been added (for bug fixes / features)

**What is the purpose of this pull request? (bug fix, enhancement, new feature,...)**

<!--
Link to the issue this pull request fixes here, if applicable: "Fixes #xxx" or "Resolves #xxx"
-->

**What changes did you make?**

**Provide some example code that this change will affect, if applicable:**

<!-- Paste the example code here: -->

**Is there anything you'd like reviewers to focus on?**

**Please provide testing instructions, if applicable:**
31 changes: 31 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Node.js CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:
name: Test
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
node-version: [10.x, 12.x, 14.x, 16.x]
os: [ubuntu-latest, macOS-latest, windows-latest]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }} on ${{ matrix.os }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npx npm@7 ci
- run: npm test
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
node_modules/*
npm-debug.log
node_modules/
npm-debug.log*
.nyc_*/
.dir-locals.el
.DS_Store
13 changes: 0 additions & 13 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2011 Charlie Robbins, Marak Squires, and the Contributors.
Copyright (c) 2011-2021 Charlie Robbins, Marak Squires, Jade Michael Thornton and the Contributors.

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
111 changes: 92 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,34 @@
[![build status](https://img.shields.io/travis/indexzero/http-server.svg?style=flat-square)](https://travis-ci.org/indexzero/http-server)
[![dependencies status](https://img.shields.io/david/indexzero/http-server.svg?style=flat-square)](https://david-dm.org/indexzero/http-server)
[![npm](https://img.shields.io/npm/v/http-server.svg?style=flat-square)](https://www.npmjs.com/package/http-server)
[![license](https://img.shields.io/github/license/indexzero/http-server.svg?style=flat-square)](https://github.com/indexzero/http-server)
![GitHub Workflow Status (master)](https://img.shields.io/github/workflow/status/http-party/http-server/Node.js%20CI/master?style=flat-square)
[![npm](https://img.shields.io/npm/v/http-server.svg?style=flat-square)](https://www.npmjs.com/package/http-server) [![homebrew](https://img.shields.io/homebrew/v/http-server?style=flat-square)](https://formulae.brew.sh/formula/http-server) ![GitHub milestone](https://img.shields.io/github/milestones/progress-percent/http-party/http-server/8?label=next%20release%20progress&style=flat-square) [![npm downloads](https://img.shields.io/npm/dm/http-server?color=blue&label=npm%20downloads&style=flat-square)](https://www.npmjs.com/package/http-server)
[![license](https://img.shields.io/github/license/http-party/http-server.svg?style=flat-square)](https://github.com/http-party/http-server)

# http-server: a command-line http server

`http-server` is a simple, zero-configuration command-line http server. It is powerful enough for production usage, but it's simple and hackable enough to be used for testing, local development, and learning.

![](https://github.com/nodeapps/http-server/raw/master/screenshots/public.png)
![Example of running http-server](https://github.com/http-party/http-server/raw/master/screenshots/public.png)

# Installing globally:
## Installation:

Installation via `npm`:
#### Globally via `npm`

npm install http-server -g
npm install --global http-server

This will install `http-server` globally so that it may be run from the command line.
This will install `http-server` globally so that it may be run from the command line anywhere.

#### Globally via Homebrew

brew install http-server

#### Running on-demand:

Using `npx` you can run the script without installing it first:

npx http-server [path] [options]
#### As a dependency in your `npm` package:

npm install http-server

## Usage:

@@ -25,42 +38,102 @@ This will install `http-server` globally so that it may be run from the command

*Now you can visit http://localhost:8080 to view your server*

**Note:** Caching is on by default. Add `-c-1` as an option to disable caching.

## Available Options:

`-p` Port to use (defaults to 8080)
`-p` or `--port` Port to use (defaults to 8080). Use `-p 0` to look for an open port, starting at 8080. It will also read from `process.env.PORT`.

`-a` Address to use (defaults to 0.0.0.0)

`-d` Show directory listings (defaults to 'True')
`-d` Show directory listings (defaults to `true`)

`-i` Display autoIndex (defaults to 'True')
`-i` Display autoIndex (defaults to `true`)

`-g` or `--gzip` When enabled (defaults to 'False') it will serve `./public/some-file.js.gz` in place of `./public/some-file.js` when a gzipped version of the file exists and the request accepts gzip encoding.
`-g` or `--gzip` When enabled (defaults to `false`) it will serve `./public/some-file.js.gz` in place of `./public/some-file.js` when a gzipped version of the file exists and the request accepts gzip encoding. If brotli is also enabled, it will try to serve brotli first.

`-e` or `--ext` Default file extension if none supplied (defaults to 'html')
`-b` or `--brotli` When enabled (defaults to `false`) it will serve `./public/some-file.js.br` in place of `./public/some-file.js` when a brotli compressed version of the file exists and the request accepts `br` encoding. If gzip is also enabled, it will try to serve brotli first.

`-e` or `--ext` Default file extension if none supplied (defaults to `html`)

`-s` or `--silent` Suppress log messages from output

`--cors` Enable CORS via the `Access-Control-Allow-Origin` header

`-o` Open browser window after starting the server
`-o [path]` Open browser window after starting the server. Optionally provide a URL path to open. e.g.: -o /other/dir/

`-c` Set cache time (in seconds) for cache-control max-age header, e.g. -c10 for 10 seconds (defaults to '3600'). To disable caching, use -c-1.
`-c` Set cache time (in seconds) for cache-control max-age header, e.g. `-c10` for 10 seconds (defaults to `3600`). To disable caching, use `-c-1`.

`-U` or `--utc` Use UTC time format in log messages.

`--log-ip` Enable logging of the client's IP address (default: `false`).

`-P` or `--proxy` Proxies all requests which can't be resolved locally to the given url. e.g.: -P http://someurl.com

`--username` Username for basic authentication [none]

`--password` Password for basic authentication [none]

`-S` or `--ssl` Enable https.

`-C` or `--cert` Path to ssl cert file (default: cert.pem).
`-C` or `--cert` Path to ssl cert file (default: `cert.pem`).

`-K` or `--key` Path to ssl key file (default: `key.pem`).

`-r` or `--robots` Provide a /robots.txt (whose content defaults to `User-agent: *\nDisallow: /`)

`-K` or `--key` Path to ssl key file (default: key.pem).
`--no-dotfiles` Do not show dotfiles

`-r` or `--robots` Provide a /robots.txt (whose content defaults to 'User-agent: *\nDisallow: /')
`--mimetypes` Path to a .types file for custom mimetype definition

`-h` or `--help` Print this list and exit.

`-v` or `--version` Print the version and exit.

## Magic Files

- `index.html` will be served as the default file to any directory requests.
- `404.html` will be served if a file is not found. This can be used for Single-Page App (SPA) hosting to serve the entry page.

## Catch-all redirect

To implement a catch-all redirect, use the index page itself as the proxy with:

```
http-server --proxy http://localhost:8080?
```

Note the `?` at the end of the proxy URL. Thanks to [@houston3](https://github.com/houston3) for this clever hack!

## TLS/SSL

First, you need to make sure that [openssl](https://github.com/openssl/openssl) is installed correctly, and you have `key.pem` and `cert.pem` files. You can generate them using this command:

``` sh
openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -keyout key.pem -out cert.pem
```

You will be prompted with a few questions after entering the command. Use `127.0.0.1` as value for `Common name` if you want to be able to install the certificate in your OS's root certificate store or browser so that it is trusted.

This generates a cert-key pair and it will be valid for 3650 days (about 10 years).

Then you need to run the server with `-S` for enabling SSL and `-C` for your certificate file.

``` sh
http-server -S -C cert.pem
```

This is what should be output if successful:

``` sh
Starting up http-server, serving ./ through https
Available on:
https:127.0.0.1:8080
https:192.168.1.101:8080
https:192.168.1.104:8080
Hit CTRL-C to stop the server
```

# Development

Checkout this repository locally, then:
13 changes: 13 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Security Policy

## Supported Versions

| Version | Supported |
|---------|------------------------|
| 0.13.x | Yes :white_check_mark: |
| 0.12.x | Security updates only |
| < 0.12 | No :x: |

## Reporting a Vulnerability

In general, vulnerabilities can be reported as an issue, pull requests are very welcome. If you'd like to report privately, please email jademichael+http-server@jmthornton.net.
Loading