Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Headers #1

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
271 commits
Select commit Hold shift + click to select a range
cb8a381
add help about caching
lanterndev Dec 11, 2013
bb6ccd6
[fix] Bump ecstatic version. Fixes #101.
indexzero Nov 6, 2014
9f06a26
[dist] Version bump. 0.7.3
indexzero Nov 6, 2014
2f4ead5
Add command alias 'hs'
Nov 12, 2014
ef57442
Merge pull request #108 from Jinkwon/master
indexzero Nov 12, 2014
ad1feda
fixes --ssl --cert and --key options
peterlcullen Nov 17, 2014
c5d7c82
Merge pull request #109 from peterlcullen/ssl-option
indexzero Nov 18, 2014
9fbfae5
[dist test] Make linting against https://github.com/indexzero/stylegu…
indexzero Dec 6, 2014
eee3952
[dist] Update a lot of dependencies.
indexzero Dec 6, 2014
4407db1
[dist] Version bump. 0.7.4
indexzero Dec 6, 2014
0c98f3f
[dist] Add .travis.yml
indexzero Dec 8, 2014
87f042e
Added SSL options to readme.
fizker Dec 9, 2014
bb362cf
Merge pull request #116 from fizker/ssl-in-readme
indexzero Dec 11, 2014
89cd93e
[dist fix] Bump to `ecstatic@0.6.0`. Fixes #122.
indexzero Feb 24, 2015
120daa2
[dist] Version bump. 0.7.5
indexzero Feb 24, 2015
75ea6bf
Add --proxy setting
jantimon Mar 4, 2015
363d928
Merge pull request #134 from jantimon/feature/node-http-proxy
indexzero Mar 4, 2015
30f4d1e
Get CORS support working with XHR preflight
Sep 5, 2014
630900f
Merge pull request #88 from paulmelnikow/corser
indexzero Mar 6, 2015
f328b20
Added logging for errors (e.g. file not found)
Feb 4, 2015
10f686a
signal handler for windows (CTRL-C to stop the server)
zonetti Feb 10, 2015
aa7c88e
Use 127.0.0.1 when listening on 0.0.0.0
1j01 Mar 1, 2015
31f16d9
[minor] Conform to project style. Clean up implementation from #132.
indexzero Mar 19, 2015
134381a
[dist] Update some dependencies.
indexzero Mar 19, 2015
991c68a
[dist] Minor package.json clean-up.
indexzero Mar 19, 2015
ca4aee6
add optional path argument for specific browser
Oct 29, 2014
ee6a65b
Add option to dynamically serve a /robots.txt
andrefs Dec 23, 2013
ac38a04
[dist] Version bump. 0.8.0
indexzero Mar 19, 2015
da2b5fe
Merge branch 'master' of github.com:indexzero/http-server
smileart-levelup Mar 20, 2015
dbd3698
Fix code-style issue on network interfaces loop
smileart-levelup Apr 16, 2015
83840b5
Add a bit more spaces to follow the general code-style
smileart-levelup Apr 16, 2015
def01f3
Merge pull request #141 from smileart/master
indexzero Jun 8, 2015
68f10ee
Allow byte range requests over CORS Fixes #156
Jun 10, 2015
48119f9
Allows explicitly setting cache to 0, closes #158
karolmajta Jun 12, 2015
ef605e8
Pass contentType to ecstatic options
gordalina Jul 28, 2015
d9200ea
Listen for sigterm and exit.
francois2metz Aug 4, 2015
b48bdf9
Merge pull request #169 from francois2metz/sigterm
indexzero Aug 4, 2015
ed8765b
Merge pull request #168 from gordalina/feature/content-type
indexzero Aug 4, 2015
16900b3
[fix] Update license to conform to modern npm syntax in package.json.…
indexzero Sep 22, 2015
ea89551
[dist] Version bump. 0.8.1
indexzero Sep 22, 2015
352ee1c
[fix dist] Update to "common-style".
indexzero Aug 1, 2015
c5a8f8d
[fix dist] More "common-style" changes.
indexzero Aug 1, 2015
40e9a25
[dist] Take dependency on `common-style`.
indexzero Sep 22, 2015
bb3e491
[dist] Finish transition to common-style@3.0.0.
indexzero Sep 22, 2015
cf7aa9a
[dist] Version bump. 0.8.2
indexzero Sep 22, 2015
044ce63
Merge pull request #157 from nickdesaulniers/corsRange
indexzero Sep 22, 2015
091e581
Merge pull request #159 from karolmajta/issue-158
indexzero Sep 22, 2015
12e5373
[dist] Version bump. 0.8.3
indexzero Sep 22, 2015
90007e2
[dist] Update .travis.yml to be more sane.
indexzero Sep 22, 2015
1c2d9ea
Complete renaming of log() to logger.info()
impleri Sep 22, 2015
9498195
Merge pull request #179 from impleri/master
indexzero Sep 22, 2015
5e014e8
[dist] Version bump. 0.8.4
indexzero Sep 22, 2015
92e7ee6
[fix] Correct weird log output and correct silent usage. Fixes #181.
indexzero Sep 26, 2015
b8975be
[dist] Version bump. 0.8.5
indexzero Sep 26, 2015
3084d67
Fix typo in README
paked Oct 4, 2015
598316d
Merge pull request #186 from paked/patch-1
indexzero Oct 5, 2015
98c0c21
UTC time format option for log messages
egikander Oct 8, 2015
a9e160d
Merge pull request #190 from egikander/log-messages-utc-option
indexzero Oct 8, 2015
99e0deb
cors headers work in progress
MichalCz Apr 14, 2015
c0f13cf
Remove console.log
MichalCz Apr 16, 2015
cffbe00
conform to style, add single cors argument
Oct 13, 2015
df51e16
tests
Oct 13, 2015
4c73585
fix quote style after merge
Oct 13, 2015
adb993f
cors extra headers test fix
Oct 13, 2015
5ed19e2
cors extra headers test fix
Oct 13, 2015
bb2ea71
Merge branch 'master' of github.com:MichalCz/http-server
Oct 13, 2015
0989c2c
remove console.log
Oct 13, 2015
f21a2fe
conform to option style
Oct 13, 2015
eb5e89a
Merge pull request #150 from MichalCz/master
indexzero Oct 17, 2015
8c58f2e
Pointing to scripts online is harmful
Oct 28, 2015
9c7f377
Merge pull request #202 from dabockster/patch-1
indexzero Oct 28, 2015
19d2b82
Fix minor typo in comments
saadq Oct 29, 2015
e95b58d
Merge pull request #203 from saadq/patch-1
indexzero Oct 30, 2015
db66b17
Updated ecstatic dependency which fixes error with Etag HTTP header o…
dpilar Nov 9, 2015
341da6c
Report correct server address
glls Nov 9, 2015
ea0eb4a
Fix space after if
glls Nov 10, 2015
4bf4e3e
Fix } and else
glls Nov 10, 2015
c30a963
Merge pull request #207 from czpilar/master
indexzero Nov 11, 2015
456fde9
Resolves indexzero/http-server#219
sgnl Dec 10, 2015
54e1077
Merge pull request #220 from sgnl/fix-url-output-fordward-slashes
indexzero Dec 10, 2015
fbd273b
Merge pull request #208 from glls/master
indexzero Feb 10, 2016
d34a3a9
[dist] Bump deps
indexzero Feb 19, 2016
0c02f82
[doc] Remove mention of Nodejitsu. Fixes #221.
indexzero Feb 19, 2016
940397c
Merge pull request #248 from indexzero/deps
indexzero Feb 19, 2016
1a8552c
[dist] Version bump. 0.9.0
indexzero Feb 19, 2016
c32ebc3
delete redundant "//"
sqlwwx Feb 26, 2016
29183e9
fixbug with -o [path]
sqlwwx Feb 26, 2016
fb00da5
format
sqlwwx Feb 26, 2016
7ad8c18
typofix
mLuby Apr 14, 2016
b456b77
Add ecstatic's gzip mode
SteveVanOpstal Jul 14, 2016
fed98f2
Merge pull request #293 from SteveVanOpstal/master
indexzero Jul 22, 2016
2dcb4bb
-t flag to control timeout
julien-f Jul 24, 2016
5da2392
Update ecstatic
Oct 12, 2016
da8bfe5
Merge pull request #319 from hmil/ecstatic-v2
indexzero Oct 12, 2016
01742b5
Aggressively turn off caching when cache time set to -1
Nov 6, 2016
541ab5d
Fix style: use single quotes for string.
Nov 6, 2016
f1f14fa
Fix style: don't use hanging indent for closing bracket.
Nov 6, 2016
413fe72
Merge pull request #268 from mLuby/patch-1
BigBlueHat Apr 25, 2017
3fc708c
Remove jitsu reference & double Usage section
BigBlueHat Apr 26, 2017
7ce3a52
Add Development section to README
BigBlueHat Apr 26, 2017
69acc8b
Add shields
BigBlueHat May 1, 2017
ef15579
Switch to flat shields
BigBlueHat May 1, 2017
a3ace13
Use safe colors to avoid header problems
Sep 19, 2016
0da0e1b
replace color properties with safe-mode calls
Sep 19, 2016
989fa1c
Upgrade portfinder to latest 1.0.13
BigBlueHat May 1, 2017
e72a42a
Add myself to the contributors
BigBlueHat May 1, 2017
a2003c1
[dist] Version bump. 0.10.0
BigBlueHat May 1, 2017
37f2dae
Update Node.js versions to latest list (> 4)
BigBlueHat May 22, 2017
9623164
Remove npm install npm line
BigBlueHat May 22, 2017
ba6db2c
Update Node.js versions to latest list (> 4)
BigBlueHat May 22, 2017
0803f36
Remove npm install npm line
BigBlueHat May 22, 2017
7e9ff0b
Remove extra slashes
jgranick Jun 9, 2017
4f3a998
Use "files" field in package.json
Oct 12, 2016
966ce9c
Adds --hide-dotfiles option
johntron Dec 4, 2015
402ad49
Merge branch 'johntron-feature/dotfiles-visibility'
BigBlueHat Jun 22, 2017
5113a57
Add HTTP Basic Auth
Feb 12, 2016
b8101bd
Add Basic Auth configuration with env varaible
Feb 12, 2016
45add9c
Use secure comparison for Basic Auth credentials
Mar 9, 2016
73fb2e8
Upgrade ecstatic to 3.0.0
BigBlueHat Jan 9, 2018
7117493
[dist] Version bump. 0.11.0
BigBlueHat Jan 9, 2018
2372798
[dist] Version bump. 0.11.1
BigBlueHat Jan 10, 2018
b9b95b2
Add README note to promote -c-1 usage
BigBlueHat Jan 10, 2018
64428b7
Optimize rasters
mathieu-aubin Jan 21, 2018
9571d0a
Add note about index & 404 magic files to README
BigBlueHat May 7, 2018
214bf79
added url option to -0
intotecho May 31, 2018
9432968
Update README for cli switch value clarity
BigBlueHat Jun 15, 2018
d328f58
Prevent vows from swallowing test errors on uncaught errors within to…
IamfromSpace Jul 14, 2018
b1b266c
Add npm package-lock (#403)
thornjad Aug 8, 2018
7f013c1
Add support for brotli encoding
thornjad Sep 3, 2018
e50fc44
Add --port alias for -p flag (#468)
Oct 4, 2018
40357dd
add compression tests
Dec 12, 2018
2cee0a3
add compression test files
Dec 12, 2018
8a3b87e
fix tests so they do what they say they do
Dec 13, 2018
0b69655
Handle proxy errors
nLight Oct 24, 2018
7564021
Point out the npx option (#488)
wmertens Jan 25, 2019
8b5b565
Update license year
thornjad Feb 3, 2019
51cdf57
add option for client IP logging
thornjad Feb 4, 2019
bfee8d4
use quotes to check switch
thornjad Feb 4, 2019
64de7f5
Add issue and pull request templates
amad-person Feb 5, 2019
74ba105
Merge pull request #503 from amad-person/add-issue-pr-templates
thornjad Feb 6, 2019
72d7614
Updated dependencies to fix security issues
chill117 Dec 24, 2018
004da3b
Merge remote-tracking branch 'upstream/master'
sqlwwx Feb 11, 2019
3e9a57f
Add README `--no-dotfiles` option
ebiiim Apr 6, 2019
9310c41
Merge pull request #499
thornjad Apr 15, 2019
c68ff7f
Merge pull request #501
thornjad Apr 15, 2019
2b11028
add thornjad to contributors
thornjad Apr 15, 2019
34467ea
ignore emacs local settings file
thornjad Apr 15, 2019
573fe58
Merge pull request #452 from IamfromSpace:preve...
thornjad Apr 15, 2019
8bc2fe0
Merge pull request #326 from ghedsouza:really-t...
thornjad Apr 15, 2019
68b48eb
Merge pull request #485 from chill117/update-de...
thornjad Apr 15, 2019
ec08b63
Merge remote-tracking branch 'upstream/master' into brotli-support
thornjad Apr 15, 2019
456f7ff
Merge pull request #245 from neoeno/master
thornjad Apr 15, 2019
597c126
add basic auth pkgs to lock
thornjad Apr 15, 2019
e703c5b
Merge pull request #477 from dcos-labs/add-prox...
thornjad Apr 15, 2019
e1f5d23
Merge remote-tracking branch 'upstream/master' into brotli-support
thornjad Apr 15, 2019
3ccddaa
Merge pull request #463 from thornjad/brotli-en...
thornjad Apr 15, 2019
c8e2cbb
Merge pull request #250 from wwx-node/master
thornjad Apr 15, 2019
2e97199
fix up wording
thornjad Apr 15, 2019
d8d001d
standardize with bin
thornjad Apr 15, 2019
c333859
Merge pull request #514
thornjad Apr 15, 2019
88ff608
add process title
thornjad Apr 16, 2019
090b08e
require at least node 6
thornjad Apr 16, 2019
801fa12
add man page
thornjad Apr 16, 2019
3cd2f00
Merge branch 'master' into update-travis-node-versions
thornjad Apr 17, 2019
36a806f
test all maintained node versions
thornjad Apr 17, 2019
f42d662
document catch-all redirect hack (#513)
thornjad May 3, 2019
975cc4f
fix issue #402 by documenting magic command to generate a SSL certifi…
epugh Aug 28, 2019
a91c95a
add a hacky and direct workaround to fix #525
Xmader Oct 23, 2019
c4956ec
add comments
Xmader Oct 23, 2019
f929c9f
upgrade vows to v0.8.3
Xmader Nov 7, 2019
458e97b
fix vows hangs after all the tests pass
Xmader Nov 7, 2019
5dcf680
use latest versions, back to 6
thornjad Nov 9, 2019
1755478
Merge pull request #572 from Xmader/fix-tests
thornjad Nov 9, 2019
de7cf70
Merge branch 'master' into update-travis-node-versions
thornjad Nov 9, 2019
afb8f4f
Merge pull request #516 from http-party/specify_engines
thornjad Nov 9, 2019
da111d6
Update travis node versions (#507)
thornjad Nov 9, 2019
a0db8f9
add process title (#515)
thornjad Nov 9, 2019
901ca49
Merge pull request #557 from epugh/master
thornjad Nov 9, 2019
dbf4881
-t flag to control timeout (#295)
thornjad Nov 9, 2019
6260536
Merge pull request #510 from ebiiim/patch-1
thornjad Nov 9, 2019
a2e7721
Merge branch 'master' into hacky-fix
Xmader Nov 9, 2019
3addf09
test on Windows
Xmader Nov 9, 2019
8028337
force to check out files with LF EOL
Xmader Nov 9, 2019
e708c79
force to install ecstatic v3.3.2 in tests
Xmader Nov 9, 2019
c1ea830
do a hacky workaround directly to the http-server package to fix… (#569)
thornjad Nov 10, 2019
f96fc99
Merge branch 'master' into test-on-windows
Xmader Nov 10, 2019
5f06ac8
bump ecstatic in package.json to ^3.3.2
Xmader Nov 10, 2019
9a0f64f
force to use ecstatic v3.3.2 in tests (#574)
thornjad Nov 11, 2019
a306ebc
Merge pull request #573 from Xmader/test-on-windows
thornjad Nov 11, 2019
0f65fc6
update readme badges to use new repo
thornjad Nov 11, 2019
6b2fe25
test on osx
thornjad Nov 11, 2019
9fa7e93
Merge pull request #575 from http-party/update-readme-badges
thornjad Nov 11, 2019
8ba09d5
Merge branch 'master' into man_page
thornjad Nov 11, 2019
3c5dfc6
Test on osx (#576)
thornjad Nov 12, 2019
cd0bbc8
SSL Certificate Checking and Grammar Fixes (#479)
dandalton1 Nov 12, 2019
7f13eed
CLI -v parameter
Nov 12, 2019
66a32d1
Add version flag.
sowmiyamuthuraman Nov 21, 2019
aa78ed6
Update README.md to include the version flag.
sowmiyamuthuraman Nov 21, 2019
d366540
correct gitignore
Nov 23, 2019
fee644f
fix repo urls
thornjad Nov 26, 2019
e6f6358
0.12.0
thornjad Nov 26, 2019
ea9ef2c
Merge pull request #580 from sowmiyamuthuraman/Fix/issue-579
thornjad Dec 11, 2019
29b82a9
Add TLS/SSL usage description (#571)
brizer Dec 16, 2019
3571e18
only add logFn function to before if logFn exists
thornjad Dec 16, 2019
b2bf057
add test for auto-ext
thornjad Dec 20, 2019
a2de1cc
when ext is html, serve text/html content type
thornjad Dec 20, 2019
316c0dc
Merge branch 'master' into CLI-v-parameter
thornjad Dec 22, 2019
3d64f84
remove unused package requiring
thornjad Dec 22, 2019
8413355
Fix bad merge
thornjad Dec 22, 2019
c600a1d
Fix bad merge yet again
thornjad Dec 22, 2019
dffd792
Add CLI --version parameter (#577)
thornjad Dec 22, 2019
cfc497b
use logger for version output
thornjad Dec 22, 2019
a5db868
Update issue template
thornjad Dec 27, 2019
b6934bc
Fix `--ext` with HTML (#590)
thornjad Jan 6, 2020
813f77d
0.12.1
thornjad Jan 8, 2020
486b4cc
ignore macOS files
thornjad Jan 8, 2020
c7901f8
update image of serving public dir
thornjad Jan 8, 2020
91ff74b
update start image
thornjad Jan 8, 2020
61668b3
update README image link
thornjad Jan 8, 2020
1572613
Update installation methods
thornjad Jan 13, 2020
e5673c5
update badges
thornjad Jan 13, 2020
7c09c23
remove broken badge
thornjad Jan 13, 2020
bd36f7b
Fix basic auth options type issue
zjhmale Dec 3, 2019
dfcc224
better start image
thornjad Jan 17, 2020
85541e5
ignore macos files
thornjad Feb 5, 2020
b2dbff5
Bump acorn from 5.7.3 to 5.7.4
dependabot[bot] Mar 15, 2020
8de3658
Merge pull request #613 from http-party/dependabot/npm_and_yarn/acorn…
thornjad Mar 16, 2020
924567f
Merge pull request #599 from http-party/new-screenshots
thornjad Mar 24, 2020
e758f03
Merge pull request #586 from http-party/logFn-skip-array
thornjad Mar 24, 2020
f5854a6
Merge pull request #584 from zjhmale/basic-auth-options-compliance
thornjad Mar 24, 2020
ed8ff1f
clarify auth types
thornjad Mar 24, 2020
454851c
Fix security issue by using Minimist directly.
adunkman Apr 9, 2020
817e11d
Upgrade sub-dependency of minimist via mkdirp.
adunkman Apr 9, 2020
943c609
Merge pull request #622 from adunkman/fix-security-vulnerability
thornjad Apr 27, 2020
95119c6
update man page
thornjad Apr 27, 2020
6e9fc08
update dependencies
thornjad Mar 24, 2020
021e9f5
update license year
thornjad Apr 27, 2020
0568097
Merge pull request #517 from http-party/man_page
thornjad Apr 27, 2020
a8f1a15
Merge pull request #581 from xxjinwei/master
thornjad Apr 27, 2020
5867a26
add testing on node 14
thornjad Apr 27, 2020
46cfd10
0.12.2
thornjad Apr 27, 2020
c0b67a9
Include doc/ in npm package
thornjad Apr 27, 2020
d7bce39
0.12.3
thornjad Apr 27, 2020
df53b9d
Mention process.env.PORT in options
ts-web Oct 12, 2020
92d5521
Merge pull request #658 from ts-web/master
thornjad Oct 13, 2020
950b6a1
Add keyword http-server
jbergens Nov 2, 2020
2e9a002
Merge pull request #1 from jbergens/jbergens-add-keyword
jbergens Nov 13, 2020
bd9c9a1
Update package.json
jbergens Dec 12, 2020
d1b7739
Merge pull request #662 from jbergens/master
thornjad Mar 9, 2021
9bfcc98
accept command line arg for a custom headers
lanterndev Jan 9, 2014
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:**
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules/*
!node_modules/node-static
npm-debug.log
node_modules/
npm-debug.log*
.dir-locals.el
.DS_Store
23 changes: 23 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
sudo: false
language: node_js
node_js:
- "6"
- "8"
- "10"
- "12"
- "13"
- "14"

git:
autocrlf: input

os:
- linux
- windows
- osx

before_install:
- travis_retry npm install

script:
- npm test
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2011 Nodejitsu http://github.com/nodejitsu/http-server/
Copyright (c) 2011-2020 Charlie Robbins, Marak Squires, and the Contributors.

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand All @@ -17,4 +17,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
144 changes: 115 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,63 +1,149 @@
[![build status](https://img.shields.io/travis/http-party/http-server.svg?style=flat-square)](https://travis-ci.org/http-party/http-server)
[![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) [![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`. If you don't have `npm` yet:
#### Globally via `npm`

curl https://npmjs.org/install.sh | sh

Once you have `npm`:
npm install --global http-server

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

#### Globally via Homebrew

brew install http-server

npm install http-server -g
#### Running on-demand:

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

npx http-server [path] [options]

This will install `http-server` globally so that it may be run from the command line.
#### As a dependency in your `npm` package:

npm install http-server

## Usage:

http-server [path] [options]

`[path]` defaults to `./public` if the folder exists, and `./` otherwise.

# Installing as a node app
*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.

mkdir myapp
cd myapp/
jitsu install http-server
## Available Options:

*If you do not have `jitsu` installed you can install it via `npm install jitsu -g`*
`-p` or `--port` Port to use (defaults to 8080). It will also read from `process.env.PORT`.

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

### Starting http-server locally
`-d` Show directory listings (defaults to `true`)

node bin/http-server
`-i` Display autoIndex (defaults to `true`)

*Now you can visit http://localhost:8080 to view your server*
`-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.

### Deploy http-server to nodejitsu
`-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.

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

*You will now be prompted for a `subdomain` to deploy your application on*
`-s` or `--silent` Suppress log messages from output

## Available Options:
`--cors` Enable CORS via the `Access-Control-Allow-Origin` header

`-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`.

`-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]

`-p` Port to listen for connections on (defaults to 8080)
`-S` or `--ssl` Enable https.

`-a` Address to bind to (defaults to '0.0.0.0')
`-C` or `--cert` Path to ssl cert file (default: `cert.pem`).

`-d` Show directory listings (defaults to 'True')
`-K` or `--key` Path to ssl key file (default: `key.pem`).

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

`-e` or `--ext` Default file extension (defaults to 'html')
`--no-dotfiles` Do not show dotfiles

`-H` or `--header` Send the specified header with responses, e.g. `-H "Strict-Transport-Security: max-age=315360000; includeSubdomains"`.

`-s` or `--silent` In silent mode, log messages aren't logged to the console.
`-h` or `--help` Print this list and exit.

`-h` or `--help` Displays a list of commands and exits.
`-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:

```sh
$ npm i
$ node bin/http-server
```

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

`-c` Set cache time (in seconds) for cache-control max-age header, e.g. -c10 for 10 seconds. To disable caching, use -c-1.
You should see the turtle image in the screenshot above hosted at that URL. See
the `./public` folder for demo content.
Loading