modifying the source code of nginx web server
I want to modify the source code of Nginx (http://n开发者_C百科ginx.org/download/nginx-0.7.67.tar.gz) so when it serves a file (reads the file from disk) to count the bytes served and store them somewhere (a datababase perhaps) Since I don't understand C that well (I'm a php developer) I have trouble finding that part in the source coude (must be a look a while or something) Can anyone help me with that? Thank you
Here is an alternate approach to access the information you want nginx to provide that is much safer.
Include bytes_sent as a column in your access log.
If you refer to the HttpLogModule you'll see you can specify bytes_sent as a column in the access log. Combine this with a php script that parses the log file (Perhaps after it is rotated) and you'll be able to avoid c.
log_format sampleformatname '$remote_addr - $remote_user [$time_local] '
'"$request" $status '
'"$http_referer" "$http_user_agent" "$bytes_sent"';
access_log /path/to/logs/access.log sampleformatname;
Some benefits to this approach:
- Ability to upgrade to newer versions of nginx without merging in your changes.
- Stick with the tools you know (php)
- offline processing
- Simpler and safer
精彩评论