GitHub - perusio/nginx-hello-world-module: A hello world module for learning Nginx module development (original) (raw)
Hello World Module for Nginx
Introduction
This module serves as a learning exercise for me, and hopefully for others too, when doing Nginx module development.
I stolethe code and added some notes using mostly Evan Miller'sNginx Module Development Guide. Also helpful is thetranslationof Vhalery Kholodov'sNginx Module Guidedone by Antoine Bonavita that also mantains a Nginx Discovery blog to document his journey on Nginx module development.
Installation
- Configure Nginx adding this module with:
Static Module : ./configure (...) --add-module=/path/to/nginx-hello-world-module
Dynamic Module: ./configure (...) --add-dynamic-module=/path/to/nginx-hello-world-module
- Build Nginx as usual with
make
. - Configure the module. There's only one directive
hello_world
that is supported in the location context only.
Example:
location = /test {
hello_world;
}
Now doing something like:
curl -i http://example.com/test
should return the hello world string as the response body.
Further reading
- English: You can go to the Nginx Planetand get a lot of Nginx related information.
- Russian: The Habrahabr Nginx Blog a treasure trove of Nginx related discussions. Use google translate or Babelfish if you don't read Russian.
TODO
- Add an argument to the
hello_world
directive specifying the language. For example:- en: hello world
- fr: bounjour monde
- pt: olá mundo
- es: hola mundo
- Make the
hello_world
directive be also defined in the if in location context (NGX_HTTP_LIF_CONF
) inngx_http_config.h
. Which implies defining a merge configuration function. - Document everything withDoxygenlinking the relevant header and source files from the Nginx core.