The developers of the Nginx presented a new instrument called ngx-rust. This instrument allows the creation of modules for the HTTP server and multi-process proxy Nginx using the programming language Rust. NGX-RUST code can be found on GitHub and is distributed under the Apache 2.0 license. Currently, it is in the beta stage of development.
The initial purpose of NGX-RUST was to develop a project for forcing the development of the ISTIO-compatible Service Mesh for the Kubernetes Platform, built on top of Nginx. Although the project remained at the prototype stage and stagnated for several years, the examples of bindings published during its creation were utilized by the community in third-party projects to enhance the capabilities of Nginx using Rust.
Later, F5 required the development of a specialized module for Nginx to protect its services. Rust language was chosen to minimize the risk of errors when working with memory. The author of NGX-RUST was then involved in developing a new and improved toolkit for creating Nginx modules using Rust.
The toolkit consists of two Crate packages:
- nginx-sys – a binding generator that uses the original Nginx code to load the Nginx code and its dependencies. It then uses Bindgen to generate the bindings over the original functions (Foreign Function Interface).
- ngx – a layer that allows Rust code to call the C functions from Nginx. The API and the re-export system of strands are created using nginx-sys.