Chinaunix首页 | 论坛 | 博客
  • 博客访问: 9267659
  • 博文数量: 1669
  • 博客积分: 16831
  • 博客等级: 上将
  • 技术积分: 12594
  • 用 户 组: 普通用户
  • 注册时间: 2011-02-25 07:23
个人简介

柔中带刚,刚中带柔,淫荡中富含柔和,刚猛中荡漾风骚,无坚不摧,无孔不入!

文章分类

全部博文(1669)

文章存档

2023年(4)

2022年(1)

2021年(10)

2020年(24)

2019年(4)

2018年(19)

2017年(66)

2016年(60)

2015年(49)

2014年(201)

2013年(221)

2012年(638)

2011年(372)

分类: 系统运维

2012-10-26 18:02:05

Nginx Java环境(tomcat)支持 connectionTimeout  

2012-10-25 11:14:36|  分类: apache_tomcat |  标签: |字号 

作者:diege

时间:2012-04-25

操作系统:FreeBSD

动静态请求相分离的一个实例

一、安装软件

1、安装nginx JDK

# cd  /usr/ports/www/nginx && make install clean

# cd /usr/ports/java/jdk16 && make install clean

这里会报错

Due to licensing restrictions, certain files must be fetched manually.

 

 Please download the Update 3 Source from

 

 and the Source Binaries from

 

 and the Mozilla Headers from

 

 .

 

 Please open

 in a web browser and follow the "Download" link for

 "JDK DST Timezone Update Tool - 1_3_45" to obtain the

 time zone update file, tzupdater-1_3_45-2011n.zip.

 

 Please download the patchset, bsd-jdk16-patches-4.tar.bz2, from

 

 

 Please place the downloaded file(s) in /usr/ports/distfiles

 and restart the build.

按提示操作

#axel -an 10 
#axel -an 10  
#axel -an 10 

下面三个文件下载放到上述同样的目录
tzupdater-1_3_34-2010o.zip 

bsd-jdk16-patches-4.tar.bz2 

diablo-latte-freebsd7-amd64-1.6.0_07-b02.tar.bz2 

#cd /usr/ports/java/jdk16 && make install clean

2、配置环境

3、安装tomcat

# /usr/ports/www/tomcat6 && make install

#echo 'tomcat60_enable="YES"' >> /etc/rc.conf

#/usr/local/etc/rc.d/tomcat6 start

配置端口

#vim /usr/local/apache-tomcat-6.0/conf/server.xml

omcat的配置可以通过两种方式来配置。
1.
通过/conf/server.xml来配置。
2.
通过可视化的界面来配置。

下面来介绍server.xml的配置:
按装完Tomcat后它的server.xml的配置内容是这样的:


connectionTimeout="2000"
它表式的是:一个客房端连接到服务器如果没有任何动作它如果超过这个时间那么它就视为无效。
2000
表式的是毫秒。


maxThreads="150"
它表示的是同一时间连接到服务器上的同一个页面时的最大连接数。

里面有三个端口配置

    

               connectionTimeout="20000"

               redirectPort="8443" />

    之间加入

二、配置

1nginx.conf添加tomcat反向代理

#vim /usr/local/etc/nginx/nginx.conf

        upstream tomcat_server{ 

                server 127.0.0.1:8180;

        }

2、站点配置文件使用反向代理。

#vim /usr/local/etc/nginx/vhosts/.conf

添加

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {

                root  /data/vhosts/;

        }

        location ~ .*\.(jsp|do)$ {

                proxy_pass

                proxy_redirect off;

                proxy_set_header Host $host;

                proxy_set_header X-Real-IP $remote_addr;

                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        }

#nginx –t

三、测试

#/usr/local/etc/rc.d/nginx reload

 

#ee /data/vhosts//test.jsp



JSP</SPAN><SPAN style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 12pt; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px; FONT-FAMILY: 宋体">测试页面<SPAN lang=EN-US style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px">


<%out.println("

Hello World!

");%>

#cp ~diege/test.jpg /data/vhosts//

访问测试

 

 

0101 Firefox/11.0"

172.17.2.160 - - [25/Apr/2012:14:59:10 +0800] "GET /test.jsp HTTP/1.1" 404 979 "-" "Mozilla/5.0 (Windows NT 5.1; rv:11.0) Gecko/20100101 Firefox/11.0"

 

cp /data/vhosts//test.jsp /usr/local/apache-tomcat-6.0/work/Catalina//

不行

cp /data/vhosts//test.jsp  /usr/local/apache-tomcat-6.0/webapps/ROOT/

 

 

172.17.2.160 - - [25/Apr/2012:15:14:10 +0800] "GET /test.jsp HTTP/1.1" 200 101 "-" "Mozilla/5.0 (Windows NT 5.1; rv:11.0) Gecko/20100101 Firefox/11.0"

 

新定义一个端口和站点

 

 

 

四、多个tomcat构建负载均衡

#vim /usr/local/etc/nginx/nginx.conf

        upstream tomcat_server{ 

                server 192.168.1.100:8080;

                                     server 192.168.1.110:8080;

                                     server 192.168.1.120:8080;

        

阅读(1091) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~