Here's how to use this module in the nginx-0.8.53 version of the specific installation method (Linux)
I. Installation and preparation
1, download nginx-0.8.53;
2, download Ngx_hmux_module_vx.x.tar package (http://code.google.com/p/nginx-hmux-module/downloads/list);
The version that is available for download here is a preliminary version and will continue to enhance its functionality as needed.
The implementation of NGX_HMUX_MODULE.C file refers to the Nginx_ajp_module module written by Yiu Weibin, which realizes the HMUX protocol and asynchronously processes the process.
Hmux protocol can refer to documentation http://www.caucho.com/resin-4.0-javadoc/com/caucho/server/hmux/HmuxRequest.html
3. (optional)
If you need to maintain keepalive between nginx and resin, and the version is lower than 1.1.4, download the KeepAlive module (http://mdounin.ru/hg/ngx_http_upstream_keepalive), and reference Http://trac.nginx.org/nginx/changeset/4116/nginx dozen good patches;
If you need session sticky, download the ngx_http_upstream_jvm_route_module.c file (http://yaoweibin.cn/).
4, in order to achieve the process asynchronous, need to modify the src/event/ngx_event_pipe.c file
The original code is as follows:
while (CL && n > 0) {
Ngx_event_pipe_remove_shadow_links (CL->BUF);
Size = cl->buf->end-cl->buf->last;
if (n >= size) {
Cl->buf->last = cl->buf->end;
/* STUB */cl->buf->num = p->num++;
if (P->input_filter (p, cl->buf) = = Ngx_error) {
return ngx_abort;
}
n-= size;
ln = CL;
CL = cl->next;
Ngx_free_chain (p->pool, LN);
} else {
Cl->buf->last + = n;
n = 0;
}
}
Modified as follows:
while (CL && n > 0) {
Ngx_event_pipe_remove_shadow_links (CL->BUF);
Size = cl->buf->end-cl->buf->last;
if (n >= size) {
Cl->buf->last = cl->buf->end;
n-= size;
} else {
Cl->buf->last + = n;
n = 0;
}
* STUB */cl->buf->num = p->num++;
if (P->input_filter (p, cl->buf) = = Ngx_error) {
return ngx_abort;
}
ln = CL;
CL = cl->next;
Ngx_free_chain (p->pool, LN);
}
The purpose of this modification is to allow Nginx to return information to the client in a timely manner, otherwise it will take a long time to return to the client.
The above changes refer to the practice of Maxim Dounin and Yiu Weibin.
The above can also be modified in the form of patches, to participate in the download package Hmux.patch and README.txt files.
Second, installation steps
The following installation steps are added to the keepalive feature:
1./configure--add-module=hmux/--add-module=keepalive/--with-debug
2, modify the Objs/makefile, remove the optimization parameters (debugging purposes)
3, make
4, make install
5, modify the nginx.conf configuration file as follows:
User xxx;
Worker_processes 2;
Debug_points abort;
Error_log Logs/error.log Debug;
PID Logs/nginx.pid;
Worker_rlimit_nofile 65536;
Events {
Use Epoll;
Epoll_events 4096;
Worker_connections 8192;
Accept_mutex off;
}
HTTP {
Include Mime.types;
Default_type Application/octet-stream;
Access_log Logs/access.log;
Sendfile on;
Tcp_nopush on;
Client_header_timeout 5;
Send_timeout 5;
Keepalive_timeout 10;
Server_name_in_redirect off;
Server_tokens off;
CharSet GB2312;
Upstream resins{
Server xxx.xxx.xxx.xxx:6800;
KeepAlive 1024;
}
server {
Listen xxxx;
server_name xxx.xxx.com;
Location/{
Hmux_pass resins;
}
}
}
Third, attention
The points to be noted here are:
1, must modify the Nginx source code or patching
2, in the single process mode, the KeepAlive module is not a problem, but in the multi-process mode,
It may be problematic to follow the instructions in the KeepAlive module. According to my experience of using keepalive in the past year
and source code analysis, in the multi-process mode to maintain and back-end resin keepalive, preferably set
Set Accept_mutex off (this will be specifically explained in my future document).
3. The document written here is extracted from the project, if there is anything that is not clear or
The wrong place, please come forward, our team will solve these problems as soon as possible.