系統(tǒng)
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 做負(fù)載均衡
192.168.1.64 tomcat1
192.168.1.66 tomcat2

分別在64和66上安裝jdk和tomcat
環(huán)境變量設(shè)置 /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本身不支持組播,因?yàn)樾枰砑咏M播
命令如下
route add -net 228.0.0.0 netmask 255.0.0.0 dev eth0
只在tomcat的其中一臺(tái)機(jī)器添加就可以了
提醒一下,記得關(guān)閉iptables和selinux

現(xiàn)在去編譯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的安裝和參數(shù)就不詳細(xì)敘述了。自己慢慢研究吧。我就這么配置起來(lái)的。現(xiàn)在session復(fù)制和負(fù)載均衡都正常了。

后續(xù)
現(xiàn)在跑應(yīng)用的時(shí)候出現(xiàn)一個(gè)奇怪的現(xiàn)象
每次提交表單查詢(xún)就會(huì)出現(xiàn)這樣的現(xiàn)象。少個(gè)問(wèn)號(hào)
https://192.168.1.62/wecs/poMemb … entMoney=1005337600
正常的應(yīng)該是下面這樣
https://192.168.1.62/wecs/poMemb … entMoney=1005337600
如果直接單獨(dú)訪(fǎng)問(wèn)tomcat1和tomcat2都是正常的。就是通過(guò)nginx的負(fù)載均衡方式訪(fǎng)問(wèn)就會(huì)出現(xiàn)這樣的現(xiàn)象
問(wèn)題已經(jīng)解決了,希望對(duì)大家能有幫助
error_page 497 “https://$host$uri$is_args$args”;
增加了$is_args