Nginx通过hmux协议访问resin说明文档

线上nginx编译参数如下:

nginx.conf的配置文件有一段

 解析:

2、下载ngx_caucho_vx.x.tar包,解开后包含两个文件:config和ngx_caucho.c;

    这里供下载的版本是初步版本,以后会随着需求不断增强其功能。

    ngx_caucho.c文件的实现参考了姚伟斌写的nginx_ajp_module模块,具体功能就是实现hmux协议,并把处理过程异步化。

    hmux协议可以参考文档 http://www.caucho.com/resin-4.0-javadoc/com/caucho/server/hmux/HmuxRequest.html

  使用hmux的目的:

a:为了能高性能代理resin

b:实现过程异步

为了更好的理解,请看如下文章:

-----------------------------------------------------------------------------------------------------------

最初公司部门内是这样访问resin的

     nginx-->resin

直接利用nginx的代理(http1.0)来访问resin,据运维人员实践结果,发现这样性能很差,于是中间加了apache这一层,于是变成这样。

     nginx-->apache-->resin

这样就初步解决了上述问题。

后来听说杭州那边写了一个nginx访问tomcat ajp的例子,于是就有了nginx访问resin hmux的需求,于是就有了这个模块。

尽管nginx-->apache-->resin初步解决了问题,但还是会存在如下问题:

  a)nginx和apache都会解析http协议,耗计算

  b)nginx和apache之间存在着性能问题,由于是http1.0访问,无法保持nginx 和apache之间的连接,在高并发情况下会极大地影响性能

  c)运维代价大

为了解决这些问题,所以尝试着开发此模块来解决上述问题,目前已经在多个项目中应用,希望开源出来大家共同努力把这个模块建设好。

http://code.google.com/p/nginx-hmux-module/

我的开源列表

http://code.google.com/u/@UxdXSldXARBMVwl4/

------------------------------------------------------------------------

        location ~/solr {

                hmux_pass hdresins;    ###只能代理resin无法代理tomcat

        # proxy_pass http://hdresins;  

}

----------------------------------------------------------------------------------------------------------

实验环境:

前端:192.168.0.192

后端resin:192.168.0.217

配置如下:

对于前端:humx.conf 

### humx wap
    upstream hdresins{
        server 192.168.0.217:6800;  #记住使用6800端口
                        } 


   server {
        listen       80;
        server_name   g.net;



        location / {
            root   /opt/nginx/html;
            index  index.html index.htm;
        }

#	location ~* /(shanghai|wuxi|kunshan|guangzhou|haikou|nanning|sanya|chengdu|kunming|chongqing|wuhan|nanchang|changsha|suzhou|nanjing|hangzhou
#	|fuzhou|nantong|ningbo|xiamen|changzhou) {
#                        hmux_pass hdresins;
#        }


        location ~/ {

		hmux_pass hdresins;
	#	proxy_pass http://hdresins;
} 





#        location /t1/ {
#            alias  /data/wwwtest/t1/;
#        }


#        location ~/t1/ {                 #不区分大小型
#            root  /data/wwwtest/;
#        }
}

对于后端:resin.properties

dev_mode      : true
resin_doc      : true
resin_doc_host :
app_servers      : 192.168.0.217:6800   #将原来的127.0.0.1改成本地内网或者外网ip地址
home_cluster : app
app.http          : 8082
web.http          : 8080
setuid_user   : 
setuid_group  : 
port_thread_max   : 256
accept_thread_max : 32
accept_thread_min : 4
tcp_cork : true
sendfile : true
keepalive_select_enable : true
proxy_cache_enable : true
session_store : true
web_admin_enable : true
web_admin_host   :

发布了56 篇原创文章 · 获赞 29 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/knight_zhou/article/details/103968509