index : static-web-server.git

ascending towards madness

author Jose Quintana <joseluisquintana20@gmail.com> 2020-01-13 22:30:17.0 +00:00:00
committer Jose Quintana <joseluisquintana20@gmail.com> 2020-01-13 22:30:17.0 +00:00:00
commit
cf0fb5349d64b1319805b6f1ee4147f3f302ea42 [patch]
tree
d3849d6bbf08b192472a6319db98ec9967c1a19a
parent
2f796bda95e59afd126a81799e86940165c6b96f
download
cf0fb5349d64b1319805b6f1ee4147f3f302ea42.tar.gz

docs: update new options usage



Diff

 README.md | 65 +++++++++++++++++++++++++++++++++++++++++-----------------------
 1 file changed, 42 insertions(+), 23 deletions(-)

diff --git a/README.md b/README.md
index d5221c9..3bed023 100644
--- a/README.md
+++ b/README.md
@@ -9,30 +9,40 @@
- Built with [Rust]https://rust-lang.org which is focused on [safety, speed, and concurrency]https://kornel.ski/rust-c-speed.
- Memory safety and reduced overhead of CPU and RAM resources.
- Blazing fast static files-serving thanks to [Rust Iron]https://github.com/iron/iron.
- Suitable for small [GNU/Linux Docker containers]https://hub.docker.com/r/joseluisq/static-web-server. It's a fully __1.8MB__ static binary thanks to [Rust and Musl libc]https://doc.rust-lang.org/edition-guide/rust-2018/platform-and-target-support/musl-support-for-fully-static-binaries.html.
- Suitable for small [GNU/Linux Docker containers]https://hub.docker.com/r/joseluisq/static-web-server. It's a fully __4,3M__ static binary thanks to [Rust and Musl libc]https://doc.rust-lang.org/edition-guide/rust-2018/platform-and-target-support/musl-support-for-fully-static-binaries.html (`x86_64-unknown-linux-musl`).
- Gzip compression by default.
- Cache control headers included.
- Configurable via environment variables or CLI arguments.
- TLS support via [Rust Native TLS]https://docs.rs/native-tls/0.2.3/native_tls/ crate.
- Lightweight logging support.
- MacOs (`x86_64-apple-darwin`) binary support thanks to [Rust Linux / Darwin Builder]https://github.com/joseluisq/rust-linux-darwin-builder.
- [Scratch]https://hub.docker.com/_/scratch and [latest Alpine Linux]https://hub.docker.com/_/alpine Docker images available.

## Usage

Server is configured either via environment variables:
Server can be configured either via environment variables or command-line arguments.

- **SERVER_NAME**: Name for server. Default `my-static-server`.
- **SERVER_HOST**: Host address (E.g 127.0.0.1). Default `[::]`.
- **SERVER_PORT**: Host port. Default `80`.
- **SERVER_ROOT**: Root directory path of static files. Default `./public`.
- **SERVER_ASSETS**: Assets directory path for add cache headers functionality. Default `./assets` but relative to the root.
- **SERVER_ERROR_PAGE_404**: HTML file path for 404 errors. If path is not specified or simply don't exists then server will use a generic HTML error message. Default `./public/404.html`.
- **SERVER_ERROR_PAGE_50X**: HTML file path for 50x errors. If path is not specified or simply don't exists then server will use a generic HTML error message. Default `./public/50x.html`.
### Environment Variables

Or command line arguments listed with `cargo run -- -h`.
| Variable | Description | Default |
| --- | --- | --- |
| `SERVER_NAME` | Name for server. | Default `my-static-server`. |
| `SERVER_HOST` | Host address (E.g 127.0.0.1). | Default `[::]`. |
| `SERVER_PORT` | Host port. | Default `80`. |
| `SERVER_ROOT` | Root directory path of static files. | Default `./public`. |
| `SERVER_ASSETS` | Assets directory path for add cache headers functionality. | Default `./assets` but relative to the root. |
| `SERVER_ERROR_PAGE_404` | HTML file path for 404 errors. | If path is not specified or simply don't exists then server will use a generic HTML error message. Default `./public/404.html`.
| `SERVER_ERROR_PAGE_50X` | HTML file path for 50x errors. | If path is not specified or simply don't exists then server will use a generic HTML error message. Default `./public/50x.html` |
| `SERVER_TLS` | Enables TLS/SSL support. Make sure also to adjust current server port. | Default `false` |
| `SERVER_TLS_PKCS12` | A cryptographic identity [PKCS #12]https://docs.rs/native-tls/0.2.3/native_tls/struct.Identity.html#method.from_pkcs12 bundle file path containing a [X509 certificate]https://en.wikipedia.org/wiki/X.509 along with its corresponding private key and chain of certificates to a trusted root. | Default empty |
| `SERVER_TLS_PKCS12_PASSWD` | A specified password to decrypt the private key. | Default empty |

### Command-line arguments

CLI arguments listed with `static-web-server -h`.

```
static-web-server 1.2.0
static-web-server 1.4.0
A blazing fast static files-serving web server powered by Rust Iron

USAGE:
@@ -43,18 +53,27 @@ FLAGS:
    -V, --version    Prints version information

OPTIONS:
        --assets <assets>      Assets directory path for add cache headers functionality [env: SERVER_ASSETS=]
                               [default: ./assets]
        --host <host>          Host address (E.g 127.0.0.1) [env: SERVER_HOST=]  [default: [::]]
        --name <name>          Name for server [env: SERVER_NAME=]  [default: my-static-server]
        --page404 <page404>    HTML file path for 404 errors. If path is not specified or simply don't exists then
                               server will use a generic HTML error message. [env: SERVER_ERROR_PAGE_404=]  [default:
                               ./public/404.html]
        --page50x <page50x>    HTML file path for 50x errors. If path is not specified or simply don't exists then
                               server will use a generic HTML error message. [env: SERVER_ERROR_PAGE_50X=]  [default:
                               ./public/50x.html]
        --port <port>          Host port [env: SERVER_PORT=]  [default: 80]
        --root <root>          Root directory path of static files [env: SERVER_ROOT=]  [default: ./public]
        --assets <assets>
            Assets directory path for add cache headers functionality [env: SERVER_ASSETS=]  [default: ./assets]

        --host <host>                              Host address (E.g 127.0.0.1) [env: SERVER_HOST=]  [default: [::]]
        --name <name>                              Name for server [env: SERVER_NAME=]  [default: my-static-server]
        --page404 <page404>
            HTML file path for 404 errors. If path is not specified or simply don't exists then server will use a
            generic HTML error message [env: SERVER_ERROR_PAGE_404=]  [default: ./public/404.html]
        --page50x <page50x>
            HTML file path for 50x errors. If path is not specified or simply don't exists then server will use a
            generic HTML error message [env: SERVER_ERROR_PAGE_50X=]  [default: ./public/50x.html]
        --port <port>                              Host port [env: SERVER_PORT=]  [default: 80]
        --root <root>
            Root directory path of static files [env: SERVER_ROOT=]  [default: ./public]

        --tls <tls>                                Enables TLS/SSL support [env: SERVER_TLS=]
        --tls-pkcs12 <tls-pkcs12>
            A cryptographic identity PKCS #12 bundle file path containing a X509 certificate along with its
            corresponding private key and chain of certificates to a trusted root [env: SERVER_TLS_PKCS12=]  [default: ]
        --tls-pkcs12-passwd <tls-pkcs12-passwd>
            A specified password to decrypt the private key [env: SERVER_TLS_PKCS12_PASSWD=]  [default: ]
```

## Docker stack