How to write a Nginx module?

2019-01-30 03:14发布

问题:

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.

回答1:

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.



回答2:

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...



回答3:

http://nutrun.com/weblog/2009/08/15/hello-world-nginx-module.html

http://blog.zhuzhaoyuan.com/2009/08/creating-a-hello-world-nginx-module



回答4:

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.



标签: plugins nginx