Scroll to navigation

http-server(1) http-server man page http-server(1)

NAME

http-server - a simple zero-configuration command-line http server

SYNOPSIS

http-server [PATH] [OPTIONS]

DESCRIPTION

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.

OPTIONS

[PATH]
The directory to serve. Defaults to ./public if it exists, and ./ otherwise.

Port to use. If 0, look for the first available port, starting at 8080. Default is 8080.

Address to use. Default is 0.0.0.0.

Show directory listings. Default is true.

Display autoIndex. Default is true.

Serve gzip files when possible. Default is false.

Serve brotli files when possible. If both brotli and gzip are enabled, brotli takes precedence. Default is false.

Default file extension is none is provided.

Suppress log messages from output.

Enable CORS via the "Access-Control-Allow-Origin" header. Optionally provide CORS headers list separated by commas.

Open default browser window after starting the server. Optionally provide a URL path to open the browser window to.

Cache time (max-age) in seconds. To disable caching, use -c -1. Default is 3600.

Use UTC time format in log messages.

Enable logging of the client IP address.

Fallback proxy if the request cannot be resolved.

Pass proxy options using nested dotted objects.

Username for basic authentication. Can also be specified with the environment variable NODE_HTTP_SERVER_USERNAME. Defaults to none.

Password for basic authentication. Can also be specified with the environment variable NODE_HTTP_SERVER_PASSWORD. Defaults to none.

Enable https.

Path to SSL certificate file. If not specified, uses cert.pem.

Path to SSL key file. If not specified, uses key.pem. Passphrase will be read from NODE_HTTP_SERVER_SSL_PASSPHRASE (if set)

Respond to /robots.txt request. If not specified, uses "User-agent: *\nDisallow: /]"

Do not show dotfiles.

Print usage and exit.

Print version and exit.

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 SPA hosting to serve the entry page.

COPYING

Copyright (c) 2011-2022 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 "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 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.

VERSION

Version 0.12.2

April 2020 GNU