我的nginx.conf:
location ~ ^/api/(.*)$ { alias /home/username/apidav/$remote_user/$1; client_body_temp_path /var/www/path/; client_max_body_size 50m; dav_methods PUT DELETE MKCOL;# COPY MOVE; create_full_put_path on; dav_access user:rw group:rw all:r; dav_ext_methods PROPFIND OPTIONS; auth_request /api_auth; } location /api_auth { internal; proxy_pass http://www.domain.ru/accounts/api_auth/; proxy_pass_request_body off; proxy_set_header Content-Length ""; proxy_set_header X-Original-URI $request_uri; }
curl -T test.txt'http :// gert:[email protected]/api/'curl :(56)Recv失败:连接重置由peer?
为什么?
tail -f /var/log/nginx/error.log
2012/11/16 17:53:42 [只有] 3 0 0 0#0:工人进程8374在信号11上退出
在auth请求之后尾debugging日志:
2012/11/16 07:00:33 [debug] 8241#0:* 1892发送100继续
2012/11/16 07:00:33 [debug] 8241#0:* 1892发送:fd:458 25的25
2012/11/16 07:00:33 [debug] 8241#0:* 1892 http读客户端请求体
2012/11/16 07:00:33 [debug] 8241#0:* 1892 recv:fd:458 -1 of 91
2012/11/16 07:00:33 [debug] 8241#0:* 1892 recv()未准备好(11:资源暂时不可用)
2012/11/16 07:00:33 [debug] 8241#0:* 1892 http client request body recv -2
2012/11/16 07:00:33 [debug] 8241#0:* 1892 http客户端请求身体rest91
2012/11/16 07:00:33 [debug] 8241#0:* 1892 event timer add:458:60000:1353027693786
2012/11/16 07:00:33 [debug] 8241#0:* 1892 http finalize request:-4,“/api/test.txt?” a:1,c:2
2012/11/16 07:00:33 [debug] 8241#0:* 1892 http请求数:2 blk:0
2012/11/16 07:00:33 [debug] 8241#0:* 1894事件0000000001789C58
2012/11/16 07:00:33 [debug] 8241#0:* 1894事件000000000179D468
2012/11/16 07:00:33 [debug] 8241#0:* 1894 delete发布事件000000000179D468
2012/11/16 07:00:33 [debug] 8241#0:* 1894 http空处理程序
2012/11/16 07:00:33 [debug] 8241#0:* 1894删除发帖是0000000001789C58
2012/11/16 07:00:33 [debug] 8241#0:* 1894 http拖延closures处理程序
2012/11/16 07:00:33 [debug] 8241#0:* 1894 recv:fd:461 0 of 4096
2012/11/16 07:00:33 [debug] 8241#0:* 1894缠绵读:0
2012/11/16 07:00:33 [debug] 8241#0:* 1894 http请求数:1 blk:0
2012/11/16 07:00:33 [debug] 8241#0:* 1894 httpclosures请求
2012/11/16 07:00:33 [debug] 8241#0:* 1894 http日志处理程序
2012/11/16 07:00:33 [debug] 8241#0:* 1894 free:0000000000000000
2012/11/16 07:00:33 [debug] 8241#0:* 1894 free:00000000016DE8A0,未使用:1
2012/11/16 07:00:33 [debugging] 8241#0:* 1894免费:0000000001605050,未使用:327
2012/11/16 07:00:33 [debug] 8241#0:* 1894closureshttp连接:461
2012/11/16 07:00:33 [debug] 8241#0:* 1894 event timer del:461:1353027638785
2012/11/16 07:00:33 [debug] 8241#0:* 1894可重用连接:0
2012/11/16 07:00:33 [debug] 8241#0:* 1894 free:00000000016610F0
2012/11/16 07:00:33 [debug] 8241#0:* 1894 free:00000000015BFAA0
2012/11/16 07:00:33 [debugging] 8241#0:* 1894免费:00000000015F0050,未使用:8
2012/11/16 07:00:33 [debugging] 8241#0:* 1894免费:000000000163E980,未使用:112
2012/11/16 07:00:33 [debug] 8241#0:* 1892 post event 0000000001789B88
2012/11/16 07:00:33 [debug] 8241#0:* 1892事件000000000179D398
2012/11/16 07:00:33 [debug] 8241#0:* 1892删除发布事件000000000179D398
2012/11/16 07:00:33 [debug] 8241#0:* 1892 http运行请求:“/api/test.txt?”
2012/11/16 07:00:33 [debugging] 8241#0:* 1892内容阶段:19
2012/11/16 07:00:33 [debug] 8241#0:* 1892 http脚本拷贝:“/ home / username / apidav /”
2012/11/16 07:00:33 [debug] 8241#0:* 1892 http script var:“gert”
2012/11/16 07:00:33 [debug] 8241#0:* 1892 http脚本复制:“/”
2012/11/16 07:00:33 [debug] 8241#0:* 1892 http script capture:“test.txt”
2012/11/16 07:00:33 [debug] 8241#0:* 1892 http put filename:“/home/username/apidav/gert/test.txt”
2012/11/16 07:00:33 [debug] 8285#0:epoll add event:fd:9 op:1 ev:00000001
2012/11/16 07:36:55 [debug] 8255#0:epoll add event:fd:9 op:1 ev:00000001
2012/11/16 07:36:55 [debug] 8285#0:epoll del事件:fd:9 op:2 ev:00000000
核心转储
(gdb)bt
src / core / ngx_file.c中的0 ngx_ext_rename_file(src = 0x8,to = 0x7fffcaa10870,ext = 0x7fffcaa10840):545
在src / http / modules / ngx_http_dav_module.c中的ngx_http_dav_put_handler(r = 0x1581fe0)中的1 0x0000000000472864:261
在src / http / ngx_http_request_body.c中的ngx_http_read_client_request_body(r = 0x1581fe0,post_handler = 0x472730)中的2 0x0000000000450a55:155
在src / http / modules / ngx_http_dav_module.c中的ngx_http_dav_handler(r = 0x1581fe0)中的3 0x0000000000473873:172
位于src / http / ngx_http_core_module.c中的ngx_http_core_content_phase(r = 0x1581fe0,ph = 0x14e7de0)中的0x0000000000443676:1403
在src / http / ngx_http_core_module.c中的ngx_http_core_run_phases(r = 0x1581fe0)中的0x000000000043e215:877
在src / http / ngx_http_request.c中的ngx_http_request_handler(ev = 0x161e9f8)中的6 0x0000000000448b13:1846
在src / event / ngx_event_posted.c中的ngx_event_process_posted(循环= 0x156be60,发布= 0x71edc0)中的0x000000000042e308:40
src / os / unix / ngx_process_cycle.c中的ngx_worker_process_cycle(cycle = 0x156be60,data =)中的8 0x0000000000434f59:806
在src / os / unix / ngx_process.c中的ngx_spawn_process(循环= 0x156be60,proc = 0x434ea0,data = 0x0,name = 0x4d4de8“工作进程”,respawn = -4)中的9 0x00000000004338b5:198
在src / os / unix / ngx_process_cycle.c中的ngx_start_worker_processes(周期= 0x156be60,n = 20,type = -4)中的0x00000000004352ca:365
src / os / unix / ngx_process_cycle.c中的ngx_master_process_cycle(cycle = 0x156be60)中的11 0x0000000000435fda:250
main(argc =,argv =)在src / core / nginx.c中的0x0000000000415efe:410
你看到的问题是两个实际问题的组合:
在nginx核心的问题,导致在某些情况下请求正文被错误地读取。 在你的情况下,这个问题是由validation请求模块触发的。 这个问题正在调查中。
dav模块中的错误,如果在dav模块的控制下没有读取到请求体,则导致nginx取消引用空指针。 这个bug在正常情况下不会performance出来,但是由于上面的问题,你已经击中了它。