51

I'm trying to find tutorials on how to build a module/plugin for Nginx web server.

Can someone help please, I just can't seem to find the appropriate tutorials.

3 Answers 3

58

Quoting from the documentation:

Evan Miller has written the definitive guide to Nginx module development. But some parts of it are a little out of date. You've been warned.

A github search turned up the Nginx Development Kit. It seems to be more up to date.

From my own personal experience, Evan Miller's guide was of a great help. You must also have a deep understanding of how NGINX works. Agentzh's tutorial can help you.

Reading the source code of his modules is always helpful too.

There is also a video tutorial that I haven't check yet, but it seems nice.

16

http://www.evanmiller.org/nginx-modules-guide.html

Nginx has a module chain. When Nginx needs to gzip or chunk-encode a response, it whips out a module to do the work. When Nginx blocks access to a resource based on IP address or HTTP auth credentials, a module does the deflecting. When Nginx communicates with Memcache or FastCGI servers, a module is the walkie-talkie...

The purpose of this guide is to teach you the details of Nginx's module chain... When you're done with the guide, you'll be able to design and produce high-quality modules that enable Nginx to do things it couldn't do before. Nginx's module system has a lot of nuance and nitty-gritty, so you'll probably want to refer back to this document often. I have tried to make the concepts as clear as possible, but I'll be blunt, writing Nginx modules can still be hard work...

2
  • have you made any progress on that? I'm kind of in the same situation here. Take a look at my post:stackoverflow.com/questions/4204812/…
    – PartySoft
    Nov 17, 2010 at 13:35
  • The bit I felt wasn't as explicit as it should be in an otherwise fantastic post was this: 'Finally, add a module directive to nginx's configuration (default is /usr/local/nginx/conf/nginx.conf) to enable the module for a location. location = /hello { hello_world; }'
    – jbg
    Jul 5, 2011 at 7:42
3

You can find an official nginx development guide here.

The end of the document leads to a new repo (6 weeks before this post) full of examples here.

Not the answer you're looking for? Browse other questions tagged or ask your own question.