Nginx module development with mysql posible?

2019-09-14 22:06发布

问题:

I'm trying to program an nginx module that discounts traffic from a Mysql database , upon a user based criteria. I don't know where to start I just know the concept of it, probably calling upon the event for sending bytes (let's say every 10 mb or so use a mysql library in C and do a query to discount the traffic) Is it possbile? can anyone give me some hints? I know there arrent' so many nginx developpers out there. I can do it on lighthttpd or apache I just need some help with it. Thank you

回答1:

I also tried to use nginx for C developments but finally opted for G-WAN.

Not only G-WAN's C scripts work faster than nginx modules but you don't have to configure anything and they play 'out-of-the-box'.

The traditional 'hello world' lets you see how this compares to nginx or Apache modules (ONLY 10 LINES OF CODE!):

http://gwan.ch/en_developers.html

One recent addition is the #prama link directive which lets you link your scripts with any existing library (just like mySQL, PostgreSQL or even SQLite).

There's an example with SQLite here:

http://gwan.ch/source/sqlite.c.txt