nginx proxy limit module development --1

The company need the post and put request to be limited. The task is add the module to nginx.

1. The research of nginx about the principle of read the client request body.

Function and description:

a. ngx_int_t ngx_http_read_client_request_body(ngx_http_request_t *r, ngx_http_client_body_handler_pt post_handler)

description:

This is the main function to read client request body.If your module need to read and process the request body, the function should be called.

b. static void

ngx_http_read_client_request_body_handler(ngx_http_request_t *r)

description:

This function is the  r->read_event_handler . ngx_http_read_client_request_body mounted the ngx_http_read_client_request_body_handler . When the read event happened, it process the

event timeout and delay state.

c. static ngx_int_t

ngx_http_do_read_client_request_body(ngx_http_request_t *r)

description:

This function is responsible  for read the body.

d. ngx_http_write_request_body

description:

This function write client request body in the temp file.

conf:

client_body_in_file_only on | clean | off;

client_body_in_single_buffer on | off;

http://blog.csdn.net/russell_tao/article/details/5637545

ngx_http_read_client_request_body提供两种保存body的方式,一种是把body存储在内存中,另一种是把body存储到临时文件里。这个临时文件也有不同的处理方法,一种是请求结束后nginx便清理掉,另外就是永久保留这个临时文件。例如下面这两个参数就会设定为每个body都存放到临时文件里,并且这个临时文件在请求结束后不会被删除:

         r->request_body_in_persistent_file = 1;

         r->request_body_in_file_only = 1;


Preread introduction:

Preread judge if the client request body has been reading .

ngx_http_read_client_request_body provide the preread .

Mark:

May be this preread can not meet our needs.

https://github.com/cfsego/limit_upload_rate/blob/master/ngx_http_limit_upload_module.c is very useful.





  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值