nginx 負載均衡 大家遇到過這樣的問題嗎,
首先介紹一下我的環境
nginx 192.168.1.62 負載均衡 ssl 埠 443 和80
tomcat1 192.168.1.64 應用 8080
tomcat2 192.168.1.66 應用 8080
session複製已經解決。就採用官方提供的方式。tomcat本身的
nginx配置文件
# grep -v "#" conf/nginx.conf
worker_processes 4;
error_log logs/error.log;
pid logs/nginx.pid;
worker_rlimit_nofile 51200;
events {
use epoll;
worker_connections 9812;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] $request '
'"$status" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log logs/access.log main;
keepalive_timeout 65;
upstream ben
{
ip_hash;
server 192.168.1.64:8080 ;
server 192.168.1.66:8080 ;
}
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;
access_log logs/host.access.log main;
location / {
root html;
index index.jsp 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://ben;
}
}
}
現在跑應用的時候出現一個奇怪的現象
每次提交表單查詢就會出現這樣的現象。少個問號
https://192.168.1.62/wecs/poMemberOrderAuditSearchList.htmlaiAgentNo=CNQ2808172&status=1&strAction=orderAudit&curAgentMoney=1005337600
正常的應該是下面這樣
https://192.168.1.62/wecs/poMemberOrderAuditSearchList.html?aiAgentNo=CNQ2808172&status=1&strAction=orderAudit&curAgentMoney=1005337600
如果直接單獨訪問tomcat1和tomcat2都是正常的。就是通過nginx的負載均衡方式訪問就會出現這樣的現象
《解決方案》
問題已經解決了,希望對大家能有幫助
error_page 497 "https://$host$uri?$args";
我的配置uri後面少了個「問號」
《解決方案》
完美的解決方法是
error_page 497 "https://$host$uri$is_args$args";
$is_args 這主要是判斷args是否帶問號。呵呵:mrgreen: