系统
Red Hat Enterprise Linux AS release 4 (Nahant Update 7)
X86_64
软件
nginx-0.6.35.tar.gz
apache-tomcat-5.5.27.tar.gz
jdk-1_5_0_17-linux-amd64.rpm
参考

http://blog.chinaunix.net/u2/83793/showart_1354266.html

http://www.sudone.com/nginx/nginx_ssl.html

http://zys.8800.org/?p=286

部署
192.168.1.62 nginx 做负载均衡
192.168.1.64 tomcat1
192.168.1.66 tomcat2

分别在64和66上安装jdk和tomcat
环境变量设置 /etc/profile
export JAVA_HOME=/usr/java/jdk1.5.0_17
export PATH=$JAVA_HOME/bin/:$PATH
export CLASSPATH=$JAVA_HOME/lib:$CATALINA_HOME/lib:.
export CATALINA_BASE=/usr/local/tomcat-5.5.27
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/apr/lib
export CATALINA_HOME=/usr/local/tomcat-5.5.27

编辑 server.xml
去掉 cluster段的注释
增加
保存
由于linux本身不支持组播,因为需要添加组播
命令如下
route add -net 228.0.0.0 netmask 255.0.0.0 dev eth0
只在tomcat的其中一台机器添加就可以了
提醒一下,记得关闭iptables和selinux

现在去编译nginx
./configure --prefix=/usr/local/nginx-0.6.35 --with-md5=/usr/lib --with-sha1=/usr/lib --with-http_ssl_module --with-http_stub
_status_module
make -j10
make install

修改nginx.conf
worker_processes 4;
pid logs/nginx.pid;
worker_rlimit_nofile 51200;
events {
use epoll;
worker_connections 9812;
}

http {
include mime.types;
default_type application/octet-stream;

sendfile on;
tcp_nopush on;

keepalive_timeout 65;

gzip on;
upstream winalite.com
{
ip_hash;
server 192.168.1.64:80;
server 192.168.1.66:80;
}
server {
listen 443;
listen 80;
server_name ec.ben.com;

ssl on;
ssl_certificate /usr/local/nginx-0.6.35/key/server07.cer;
ssl_certificate_key /usr/local/nginx-0.6.35/key/server07.pem;
ssl_session_timeout 5m;
ssl_protocols SSLv2 SSLv3 TLSv1;
ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
ssl_prefer_server_ciphers on;
error_page 497 “https://$host$uri?$args”;
location / {
root html;
index index.html index.htm;
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;
proxy_pass http://winalite.com;
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
nginx的安装和参数就不详细叙述了。自己慢慢研究吧。我就这么配置起来的。现在session复制和负载均衡都正常了。

后续
现在跑应用的时候出现一个奇怪的现象
每次提交表单查询就会出现这样的现象。少个问号
https://192.168.1.62/wecs/poMemb … entMoney=1005337600
正常的应该是下面这样
https://192.168.1.62/wecs/poMemb … entMoney=1005337600
如果直接单独访问tomcat1和tomcat2都是正常的。就是通过nginx的负载均衡方式访问就会出现这样的现象
问题已经解决了,希望对大家能有帮助
error_page 497 “https://$host$uri$is_args$args”;
增加了$is_args