Getting Started
Prerequisites
- Linux Kernel Support: IO-uring requires a Linux kernel version that includes IO-uring support. Generally, kernel versions 5.1 and above provide the necessary support. Ensure that your target system has an appropriate kernel version installed. Monolake will fall back to epoll on Mac OS.
- Rust nightly: See the “Rust installation section” below
Quick Start
This chapter will get you started with Monolake using a simple example config
Rust installation
To download and install Rust, and set rustup
to nightly, you can follow these instructions:
-
Download and install Rust by running the following command in your terminal:
$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
This command will download the Rust installation script and initiate the installation process.
-
Close the terminal and open a new terminal window to ensure the changes take effect.
-
Set
rustup
to nightly by running the following command:$ rustup default nightly
This command sets the default Rust toolchain to the nightly version.
-
Verify the installation and check the Rust version by running:
$ rustc --version
This command will display the installed Rust version, which should now be set to nightly.
Setup an HTTP upstream server
-
Install Nginx: Install Nginx using the package manager of your Linux distribution.
-
Start Nginx: Start Nginx using the following command:
sudo service nginx start
-
Configure Port: Open the Nginx configuration file using a text editor:
sudo nano /etc/nginx/nginx.conf
Inside the file, locate the
http
block and add or modify thelisten
directive to use port 9080:http { ... server { listen 9080; ... } ... }
Save the changes and exit the text editor.
-
Restart Nginx: Restart Nginx for the changes to take effect:
sudo service nginx restart
Build Monolake
-
Clone the monolake repository
git clone https://github.com/cloudwego/monolake.git
. -
Build the binary:
$ cargo build --release
-
Generate the certificates
$ sh examples/gen_cert.sh
Run the example
- Make sure your endpoints are up and certificates are generated
- Start the proxy
$ ./target/release/monolake -c examples/config.toml
- Send a request to the socket based listener on server_basic.
$ curl -vvv http://127.0.0.1:9081/
- Send a request to the server_tls.
$ curl --resolve gateway.monolake.rs:8081:127.0.0.1 --cacert examples/certs/rootCA.crt -vvv https://gateway.monolake.rs:8081/
Detail configuration
Please check Configuration for more details.