yaoweibin / nginx_ajp_module

support AJP protocol proxy with Nginx
http://github.com/yaoweibin/nginx_ajp_module
246 stars 60 forks source link

ajp模块设计问题 #21

Open wangbin579 opened 10 years ago

wangbin579 commented 10 years ago

假设nginx.conf部分配置如下:

upstream tomcats {
        server 10.150.12.190:9009;
        keepalive 1024;
}

upstream backup{
        server 10.150.12.190:8009;
        keepalive 1024;
}

server {
    listen 6000 backlog=1024;

    server_name test.163.com;
    client_max_body_size 128m;
    location @fallback {
            expires    -1;
            ajp_keep_conn on;
            ajp_pass backup;
    }
    location  /{
            ajp_keep_conn on;
            ajp_pass tomcats;
            error_page 502 503 504 @fallback;
    }
}

用户访问如下: curl -v 'http://10.150.12.190:6000/test.jsp' -d 'ddd' nginx会先访问10.150.12.190:9009,出现50x错误的时候,走error_page,继续访问10.150.12.190:8009,但由于nginx ajp模块对body的数据中的buffer指针做了如下修改: b_out->file_last = b_in->file_pos = b_in->file_last; b_in->file_pos += max_size - size; b_out->last = b_in->pos = b_in->last; b_in->pos += max_size - size;

导致问题如下: 1)无法把post数据传递过去 2)由于指针做了修改,易崩溃 ./nginx_ajp -c /usr/local/nginx/conf/nginx.conf_ajp_2014 Aborted

其它proxy,都不会修改body缓冲区的指针的,所以不会出现类似nginx ajp的问题