diff --git a/readme.md b/readme.md index 5766003..62f3889 100755 --- a/readme.md +++ b/readme.md @@ -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? @@ -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 @@ -68,48 +73,62 @@ You can use the command line options to override the default configuration. Options: ``` - -r, -root= Root path of the site. Default is current working directory. - -p, -port= HTTP port. Default is 8080. - -404= Path of a custom 404 file, relative to Root. Example: /404.html. - -i, -index= 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= 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= Serve all paths even if the path is start with dot. - -g, -gzip= Turn on or off gzip compression. Default value is true (means turn on). - - -am, -auth-method= Set authentication method, valid values are basic and digest. Default is basic. - -a, -auth= Turn on authentication and set username and password (separate by colon). - After turn on authentication, all the page require authentication. - -401= 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= HTTPS port. Default is 443. - -tls-policy= 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= Load a file as a certificate. - If use with -make-cert, will generate a certificate to the path. - -key= Load a file as a private key. - If use with -make-cert, will generate a private key to the path. + -r, -root= Root path of the site. Default is current working directory. + -p, -port= HTTP port. Default is 8080. + -404= Path of a custom 404 file, relative to Root. Example: /404.html. + -i, -index= 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= 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= Serve all paths even if the path is start with dot. Default is false. + -g, -gzip= Turn on or off gzip compression. Default value is true (means turn on). + + -nc, -no-cache= 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= 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= Set authentication method, valid values are basic and digest. Default is basic. + -a, -auth= Turn on authentication and set username and password (separate by colon). + After turn on authentication, all the page require authentication. + -401= 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= HTTPS port. Default is 443. + -tls-policy= 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= Load a file as a certificate. + If use with -make-cert, will generate a certificate to the path. + -key= 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. @@ -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.