archive
/
tstatic
Archived
1
Fork 0
This repository has been archived on 2023-03-26. You can view files and clone it, but cannot push or open issues or pull requests.
tstatic/README.md

73 lines
2.4 KiB
Markdown
Raw Permalink Normal View History

2017-02-20 08:58:08 +00:00
# tstatic
[![CircleCI](https://img.shields.io/circleci/project/github/RealOrangeOne/tstatic.svg?style=flat-square)](https://circleci.com/gh/RealOrangeOne/tstatic/)
[![npm](https://img.shields.io/npm/dm/tstatic.svg?style=flat-square)](https://www.npmjs.com/package/tstatic)
[![npm](https://img.shields.io/npm/v/tstatic.svg?style=flat-square)](https://www.npmjs.com/package/tstatic)
2017-01-21 23:15:59 +00:00
The only static-file server you'll ever need!
2016-05-16 13:20:30 +01:00
2017-01-21 23:15:59 +00:00
### Features:
2017-02-17 22:13:36 +00:00
- Basic-Auth - [`basic-auth`](https://www.npmjs.com/package/basic-auth)
2017-01-21 23:15:59 +00:00
- Custom 404 page
- Optimum Compression - [`compression`](https://www.npmjs.com/package/compression)
- Security checks / headers - [`helmet`](https://www.npmjs.com/package/helmet)
2017-02-17 22:13:36 +00:00
- Whitelist IP Addresses - [`express-ip-access-control`](https://www.npmjs.com/package/express-ip-access-control)
- Directory Listing - [`serve-index`](https://www.npmjs.com/package/serve-index)
2016-05-16 13:20:30 +01:00
2017-02-17 22:13:36 +00:00
### Usage
2017-01-21 23:15:59 +00:00
```bash
2017-02-17 22:13:36 +00:00
tstatic <dir> [options]
2017-02-20 08:58:08 +00:00
2017-02-17 22:13:36 +00:00
-h --help Show this screen.
--version Show version.
-p <port> --port=<port> Port to listen on.
-b <auth> --basic-auth=<auth> Enable basic-auth.
-i <ips> --ips=<ips> Allowed IP addresses.
-l --list-dir List Directory.
-o --open Open in browser after start.
2017-01-21 23:15:59 +00:00
```
2017-02-17 22:13:36 +00:00
`dir` is where your static files are.
2016-05-16 13:20:30 +01:00
2017-02-17 22:13:36 +00:00
404 errors will return with `<dir>/.404.html`, with status code 404. If this file doesnt exist, the default error page will be shown.
2016-05-16 13:20:30 +01:00
2017-02-17 22:13:36 +00:00
### Configuration
2017-01-21 23:15:59 +00:00
2017-02-17 22:13:36 +00:00
##### `port`
The port for the server to listen on. Currently supports plain HTTP only
2017-01-21 23:15:59 +00:00
2017-02-17 22:13:36 +00:00
##### `basic-auth`
Enable basic-auth for all paths. Currently only supports single credentals.
2017-01-21 23:15:59 +00:00
2017-02-17 22:13:36 +00:00
Format:`-b username:password`
2017-01-21 23:15:59 +00:00
2017-02-17 22:13:36 +00:00
##### `ips`
IP addresses that are allowed to connect to the server.
Format: `-i 192.168.1.100,192.168.1.101`
##### `list-dir`
Enables directory listing. Allow browseing
##### `open`
Open the server in the browser one started. It will open in your default browser, and use url `http://0.0.0.0:<port>`.
2018-01-26 19:56:43 +00:00
### Docker
2018-05-05 12:02:10 +01:00
Included in this repo is a `Dockerfile` to use. The default setup requires being run from the project directory, and will serve `/var/www` in the container on port `5000`. By default, this directory is contains a simple index file, however can be overriden.
2018-01-26 19:56:43 +00:00
Below is an example `docker-compose.yml` file you can use with it:
```yml
version: "2"
services:
tstatic:
image: "tstatic"
build:
context: .
dockerfile: Dockerfile
volumes:
- ./site/:/var/www
2018-01-26 19:56:43 +00:00
ports:
- "5000:5000"
```