Hi, rust-web-server (rws) is a simple web-server written in Rust. The rws server can serve static content inside the directory it is started.
Currently, you can download binary from releases page. Also, you can clone the repository and build rws binary for other platforms. There is a mirror for downloads on Google Drive.
Simply add downloaded rws binary to $PATH. To check installation execute the following code:
$ rws
You will see similar output:
Rust Web Server
Version: 0.0.28
Authors: Bohdan Tsap bohdan.tsap@tutanota.com
Repository: https://github.com/bohdaq/rust-web-server
Desciption: rust-web-server (rws) is a simple web-server written in Rust. The rws http server can serve static content inside the directory it is started.
Rust Version: 1.64
Simply run the following from command line:
$ rws --ip=127.0.0.1 --port=8888 --threads=100
Make sure in the folder where you execute rws there are index.html and 404.html files.
The rws can be started without any configuration. The following is the default config - the server will bind to IP 127.0.0.1 and port 7887, will spawn 200 threads, CORS requests are allowed.
The rws will try to read configuration from system environment variables first, then it will override configuration by reading it from file named rws.config.toml placed in the same directory where you execute rws, at last it will apply config provided via command-line arguments.
I personally prefer to use system environment variables, as once it is set correctly, they are hard to break accidentally by overwriting config, or each time providing command line arguments during restarts.
There may be a use case when you need to run more than one instance, in such a case config file per instance or command line configuration is an option.
If you want to build rust-web-server on your own, make sure you have Rust installed.
Minimum rust version is 1.64, as I'm testing on this specific version. However, if needed you may try to build rws on your own using older version with the --ignore-rust-version flag.
$ cargo build --release
$ cd target/release
$ ./rws --ip=127.0.0.1 --port=8888 --threads=100
Rust Web Server has a Discord where you can ask questions and share ideas. Follow the Rust code of conduct.
The rws is an HTTP server. This means if you are planning to use it somewhere else except the local machine you need to protect transferred data by using encryption.
The most common use cases are: 1. You need your webapp to be globally available via the internet. In such a case, the simplest solution is to use a reverse proxy and certificate provided by Let's Encrypt. A proxy will redirect all HTTP traffic to HTTPS, decrypt it via certificate and forward the request to rws. Response from rws will be forwarded to a proxy, encrypted, and send to a client. As reverse proxy you may use Apache HTTP Server, lighttpd, etc. 2. You don't need your webapp to be globally available. In such case the solution may be to setup VPN.
As any other application, rws will allocate memory required to serve the request. For example if the client will make an HTTP GET for resource which has size more than free available memory on the running instance, rws will throw Out Of Memory error.
In such case valid options are: 1. Use range requests on the client for big resources to get a portion at a time. 2. Balance the overall load on instance in case you have heavy load by spinning up more rws instances and share traffic between them.
If you appreciate my work and want to support it, feel free to do it via PayPal.