Skip to content

Commit

Permalink
update readme for v0.1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
m3ng9i committed Apr 7, 2019
1 parent 1b8aefe commit 45c13ef
Showing 1 changed file with 64 additions and 37 deletions.
101 changes: 64 additions & 37 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Ran is a simple web server for serving static files.
- Access logging
- Custom 401 and 404 error file
- TLS encryption
- Disable content caching
- Write cross-origin resource sharing headers to the response

## What is Ran for?

Expand Down Expand Up @@ -57,7 +59,10 @@ Root directory | the current working directory
Port | 8080
Index file | index.html, index.htm
List files of directories | false
Serve all path | false
Gzip | true
Disable caching | false
Write cross-origin headers | false
Digest auth | false
TLS encryption | off

Expand All @@ -68,48 +73,62 @@ You can use the command line options to override the default configuration.
Options:

```
-r, -root=<path> Root path of the site. Default is current working directory.
-p, -port=<port> HTTP port. Default is 8080.
-404=<path> Path of a custom 404 file, relative to Root. Example: /404.html.
-i, -index=<path> File name of index, priority depends on the order of values.
Separate by colon. Example: -i "index.html:index.htm"
If not provide, default is index.html and index.htm.
-l, -listdir=<bool> When request a directory and no index file found,
if listdir is true, show file list of the directory,
if listdir is false, return 404 not found error.
Default is false.
-sa, -serve-all=<bool> Serve all paths even if the path is start with dot.
-g, -gzip=<bool> Turn on or off gzip compression. Default value is true (means turn on).
-am, -auth-method=<auth> Set authentication method, valid values are basic and digest. Default is basic.
-a, -auth=<user:pass> Turn on authentication and set username and password (separate by colon).
After turn on authentication, all the page require authentication.
-401=<path> Path of a custom 401 file, relative to Root. Example: /401.html.
If authentication fails and 401 file is set,
the file content will be sent to the client.
-tls-port=<port> HTTPS port. Default is 443.
-tls-policy=<pol> This option indicates how to handle HTTP and HTTPS traffic.
There are three option values: redirect, both and only.
redirect: redirect HTTP to HTTPS
both: both HTTP and HTTPS are enabled
only: only HTTPS is enabled, HTTP is disabled
The default value is: only.
-cert=<path> Load a file as a certificate.
If use with -make-cert, will generate a certificate to the path.
-key=<path> Load a file as a private key.
If use with -make-cert, will generate a private key to the path.
-r, -root=<path> Root path of the site. Default is current working directory.
-p, -port=<port> HTTP port. Default is 8080.
-404=<path> Path of a custom 404 file, relative to Root. Example: /404.html.
-i, -index=<path> File name of index, priority depends on the order of values.
Separate by colon. Example: -i "index.html:index.htm"
If not provide, default is index.html and index.htm.
-l, -listdir=<bool> When request a directory and no index file found,
if listdir is true, show file list of the directory,
if listdir is false, return 404 not found error.
Default is false.
-sa, -serve-all=<bool> Serve all paths even if the path is start with dot. Default is false.
-g, -gzip=<bool> Turn on or off gzip compression. Default value is true (means turn on).
-nc, -no-cache=<bool> If true, ran will remove Last-Modified header and write some no-cache headers to the response:
Cache-Control: no-cache, no-store, must-revalidate
Pragma: no-cache
Expires 0
Default is false.
-cors=<bool> If true, ran will write some cross-origin resource sharing headers to the response:
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: *
Access-Control-Allow-Headers: *
If the request header has a Origin field, then it's value is used in Access-Control-Allow-Origin.
Default is false.
-am, -auth-method=<auth> Set authentication method, valid values are basic and digest. Default is basic.
-a, -auth=<user:pass> Turn on authentication and set username and password (separate by colon).
After turn on authentication, all the page require authentication.
-401=<path> Path of a custom 401 file, relative to Root. Example: /401.html.
If authentication fails and 401 file is set,
the file content will be sent to the client.
-tls-port=<port> HTTPS port. Default is 443.
-tls-policy=<pol> This option indicates how to handle HTTP and HTTPS traffic.
There are three option values: redirect, both and only.
redirect: redirect HTTP to HTTPS
both: both HTTP and HTTPS are enabled
only: only HTTPS is enabled, HTTP is disabled
The default value is: only.
-cert=<path> Load a file as a certificate.
If use with -make-cert, will generate a certificate to the path.
-key=<path> Load a file as a private key.
If use with -make-cert, will generate a private key to the path.
```

Other options:

```
-make-cert Generate a self-signed certificate and a private key used in TLS encryption.
You should use -cert and -key to set the output paths.
-showconf Show config info in the log.
-debug Turn on debug mode.
-v, -version Show version information.
-h, -help Show help message.
-make-cert Generate a self-signed certificate and a private key used in TLS encryption.
You should use -cert and -key to set the output paths.
-showconf Show config info in the log.
-debug Turn on debug mode.
-v, -version Show version information.
-h, -help Show help message.
```

If you want to shutdown Ran, type `ctrl+c` in the terminal, or kill it in the task manager.
Expand Down Expand Up @@ -214,6 +233,14 @@ Read the source code of [CanBeCompressed()](https://github.com/m3ng9i/go-utils/b

## Changelog

- **v0.1.4**:

- Add `-no-cache` option to disable content caching
- Add `-cors` option to write cross-origin resource sharing headers to the response
- Record the X-Real-Ip field in the request header to the log
- Fix bug of file not being closed after opening
- Use HTML template for directory listing (thanks to @toby)

- **v0.1.3**:

- Add trailing slash if the request path is a directory and the directory contains a index file.
Expand Down

0 comments on commit 45c13ef

Please sign in to comment.