Now, my envir is Ngnix 1.4.2+Jboss as 7.i met some questions about load balance. It's not any question when i using ip_hash.But,if i using weight ,i can't login my app, will be logout my app when i enter user and pass.
The below is the content of access.log. it's be logout myapp after login. it's no problem if using ip hash.:
192.168.6.143 - - [10/Oct/2013:10:15:19 +0800] "GET /myapp/ HTTP/1.1" 302 0 "-" "Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Firefox/24.0"
192.168.6.143 - - [10/Oct/2013:10:15:19 +0800] "GET /myapp/index.action HTTP/1.1" 302 0 "-" "Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Firefox/24.0"
192.168.6.143 - - [10/Oct/2013:10:15:19 +0800] "GET /myapp/logout.jsp HTTP/1.1" 200 876 "-" "Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Firefox/24.0"
192.168.6.143 - - [10/Oct/2013:10:15:19 +0800] "GET /myapp/login.action HTTP/1.1" 200 10295 "http://192.168.6.143/myapp/logout.jsp" "Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Firefox/24.0"
192.168.6.143 - - [10/Oct/2013:10:15:24 +0800] "POST /myapp/j_spring_security_check HTTP/1.1" 302 0 "http://192.168.6.143/myapp/login.action" "Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Firefox/24.0"
192.168.6.143 - - [10/Oct/2013:10:15:24 +0800] "GET /myapp/ HTTP/1.1" 302 0 "http://192.168.6.143/mypp/login.action" "Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Firefox/24.0"
192.168.6.143 - - [10/Oct/2013:10:15:24 +0800] "GET /uma-unimax-web/logout.jsp HTTP/1.1" 200 876 "http://192.168.6.143/uma-unimax-web/login.action" "Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Firefox/24.0"
192.168.6.143 - - [10/Oct/2013:10:15:24 +0800] "GET /uma-unimax-web/login.action HTTP/1.1" 200 10295 "http://192.168.6.143/uma-unimax-web/logout.jsp" "Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Firefox/24.0"
The below is my nginx conf:
upstream myapp {
#ip_hash;
server 10.1.1.199:8331 weight=5 max_fails=3 fail_timeout=30s;
server 10.1.1.199:8330 weight=5 max_fails=3 fail_timeout=30s;
}
server {
listen 80;
server_name 192.168.6.143;
large_client_header_buffers 4 16k;
client_max_body_size 300m;
client_body_buffer_size 128k;
proxy_connect_timeout 3;
proxy_read_timeout 3;
proxy_send_timeout 5;
proxy_buffer_size 64k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
include block_session.conf;
#charset koi8-r;
location ~ ^/status {
stub_status on; #Nginx monitor
access_log off;
}
location ~ ^/(WEB-INF)/ {
deny all;
}
location / {
#root html;
#index index.html index.htm;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#proxy_set_header Host $http_host;
#proxy_set_header X-NginX-Proxy true;
proxy_pass http://myapp;
#proxy_redirect off;
#proxy_pass_header Set-Cookie;
}