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.

Ivan Shatsky
  • 13,267
  • 2
  • 21
  • 37
user63898
  • 29,839
  • 85
  • 272
  • 514

3 Answers3

59

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.

jbochi
  • 28,816
  • 16
  • 73
  • 90
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...

gnat
  • 6,213
  • 108
  • 53
  • 73
  • have you made any progress on that? I'm kind of in the same situation here. Take a look at my post:http://stackoverflow.com/questions/4204812/nginx-module-development-with-mysql-posible – PartySoft Nov 17 '10 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 05 '11 at 07: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.

dhoodlum
  • 1,103
  • 2
  • 9
  • 18