Skip to content

A simple implementation of a dynamic NGINX module written in rust

Notifications You must be signed in to change notification settings

Spazzy757/hello-ngx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hello NGINX Rust Module

This is a small POC to build a Dynamic Nginx Rust module using rust. This is heavily influenced from the curl examples used in ngx-rust crate but is used as a learning tool to see how the different components interact for beginners.

Getting Started

We run a simple docker compose setup injecting a custom nginx.conf into the container. Therefore all you need to do is run:

docker compose up -d

Note this will probably take a fair amount of time

Testing how the Module Works

You can test how the module works by making the following curl requests:

curl http://127.0.0.1:8000 -v -H "user-agent: hello-ngx"

While this will return a simple 200 status code if you look in the NGINX logs you will see a little surprise

...
2023/06/23 10:34:26 [debug] 1#1: *1 hello world module enabled: true
2023/06/23 10:34:26 [debug] 1#1: *1 Hello Rusty NGINX
...

Files of Note

There are two files to look into;

  • hello_ngx.rs: This is the custom module that gets created
  • nginx.conf: This is the nginx configuration that makes use of the custom nginx module

About

A simple implementation of a dynamic NGINX module written in rust

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published