liveBook · Manning

NGINX

As explained in Refactoring to Rust

NGINX is a high-performance web server and reverse proxy that can process HTTP requests and load application modules.

NGINX can load a Rust-backed HTTP handler as a dynamic module. A small C layer supplies module initialization, while Rust provides the handler implementation. section 4.2

A practical integration workflow is:

  • Download NGINX 1.19.3 and create a Cargo library crate. section 4.1
  • Create a module configuration script and C starter file with HTTP hooks and a calculation directive. section 4.2
  • Configure NGINX with the module, build the module and binary, then load the resulting shared object. section 4.2
  • Run the server with a location such as /calculate and enable the module through nginx.conf. section 4.2
$ cargo new --lib ngx_http_calculator_rs
$ cd ngx_http_calculator_rs
$ wget https://nginx.org/download/nginx-1.19.3.tar.gz
$ tar -xfz nginx-1.19.3.tar.gz

Use the command listing to create the crate, download the NGINX source, and extract the release archive. section 4.1

How Refactoring to Rust covers it

How deep it goes
Defines source download, C scaffolding, configuration, compilation, and launch, but defers the full NGINX C API and Rust implementation.
Examples
Uses a calculator module, a /calculate location, nginx.conf, and an ngx_http_calculator.so build artifact.
What it assumes
Introduces module setup while deliberately deferring a full guide to NGINX’s large and complicated C API.
What you can do after
Builds a starter dynamic module and launches NGINX with a configured /calculate location.
How it connects
Connects dynamic modules with HTTP handlers, C APIs, Cargo crates, Rust functions, and reverse-proxy server operation.

Also explained in

Compare how 3 books explain NGINX →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Refactoring to Rust. The section links point to the parts of the book it draws on.