nginx和Struts2遇到redirectAction进不进去的问题,求助!
非常诡异蛋疼的问题:
我用的是nginx对应8080 和 8081两个服务做的负载均衡,但是业务逻辑中用到了Struts的redirectAction。蛋疼是其它浏览器都正常跳转,只在IE8中redirectAction走不进去。
配置如下:
nginx 配置----------------
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 50000;
}
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;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#禁止nginx显示端口号
port_in_redirect off;
#开启gzip模块
#gzip on;
#gzip_min_length 1100;
#gzip_buffers 4 8k;
#gzip_types text/plain application/x-javascript text/css application/xml;
#output_buffers 1 32k;
#postpone_output 1460;
#server_names_hash_bucket_size 128;
#client_max_body_size 8m;
#开启404错误定向跳转
fastcgi_intercept_errors on;
#fastcgi_connect_timeout 300;
#fastcgi_send_timeout 300;
#fastcgi_read_timeout 300;
#fastcgi_buffer_size 64k;
#fastcgi_buffers 4 64k;
#fastcgi_busy_buffers_size 128k;
#fastcgi_temp_file_write_size 128k;
#gzip_http_version 1.1;
#gzip_comp_level 2;
#gzip_vary on;
upstream www_tomcat {
#根据ip计算将请求分配各那个后端tomcat,可以解决session问题
ip_hash;
#weigth参数表示权值,权值越高被分配到的几率越大但是当负载调度算法为ip_hash时,后端服务器在负载均衡调度中的状态不能是weight和backup
server 127.0.0.1:8080 max_fails=1 fail_timeout=2;
server 127.0.0.1:8081 max_fails=1 fail_timeout=2;
#linux补丁,对这个负载均衡条目中的所有节点,每3秒检测一次,请求2次正常则标记 realserver状态为up,如果检测 5 次都失败,则标记 realserver的状态为down,超时时间为1秒。
#check interval=3000 rise=2 fall=5 timeout=1000 type=http;
}
upstream mobile_tomcat{
server 127.0.0.1:8082 ;
}
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
#手机设备访问不同应用服务
#这里大小写敏感,~*无视大小写。
if ($http_user_agent ~ "((MIDP)|(WAP)|(UP.Browser)|(Smartphone)|(Obigo)|(Mobile)|(AU.Browser)|(wxd.Mms)|(WxdB.Browser)|(CLDC)|(UP.Link)|(KM.Browser)|(UCWEB)|(SEMC\-Browser)|(Mini)|(Symbian)|(Palm)|(Nokia)|(Panasonic)|(MOT)|(SonyEricsson)|(NEC)|(Alcatel)|(Ericsson)|(BENQ)|(BenQ)|(Amoisonic)|(Amoi)|(Capitel)|(PHILIPS)|(SAMSUNG)|(Lenovo)|(Mitsu)|(Motorola)|(SHARP)|(WAPPER)|(LG)|(EG900)|(CECT)|(Compal)|(kejian)|(Bird)|(BIRD)|(G900/V1.0)|(Arima)|(CTL)|(TDG)|(Daxian)|(DAXIAN)|(DBTEL)|(Eastcom)|(EASTCOM)|(PANTECH)|(Dopod)|(Haier)|(HAIER)|(KONKA)|(KEJIAN)|(LENOVO)|(Soutec)|(SOUTEC)|(SAGEM)|(SEC)|(SED)|(EMOL)|(INNO55)|(ZTE)|(iPhone)|(Android)|(Windows CE)|(Wget)|(Java)|(curl)|(Opera))" )
{
#proxy_pass http://mobile_tomcat;
#rewrite $ http://127.0.0.1:8080/com/login.action permanent;
}
#空的UA默认为手机访问。
if ( $http_user_agent ~ ^$ )
{
#proxy_pass http://mobile_tomcat;
#rewrite $ http://127.0.0.1:8080/com/login.action permanent;
}
proxy_pass http://www_tomcat;
proxy_redirect off;
proxy_set_header Host $host:80;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#跟后端服务器连接超时时间 发起握手等候响应超时时间
proxy_connect_timeout 1;
#连接成功后 等待后端服务器响应时间 其实已进入后端的排队之中等候处理
proxy_read_timeout 90;
#后端服务器数据回传时间 就是在规定时间内后端服务器必须传完所有数据
proxy_send_timeout 90;
#代理请求缓存区 这个缓存区间会保存用户的头信息一共Nginx进行规则处理 一般只要能保存下头信息即可
proxy_buffer_size 4k;
#同上 告诉Nginx保存单个用的几个Buffer最大用多大空间
proxy_buffers 4 32k;
#如果系统很忙的时候可以申请国内各大的proxy_buffers 官方推荐 *2
proxy_busy_buffers_size 64k;
#proxy 缓存临时文件的大小
proxy_temp_file_write_size 64k;
proxy_next_upstream error timeout invalid_header http_500 http_503 http_404;
proxy_max_temp_file_size 128m;
}
# redirect server error pages to the static page /50x.html
#
error_page 404 500 502 503 504 /error.htm;
location = /error.htm {
root html/404/;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
Struts 配置--------------------
<result name="settlement" type="redirectAction">
<param name="ActionName">interface/toSettlement</param>
<param name="product_info">${product_info}</param>
<param name="total_money">${total_money}</param>
<param name="pay_id">${pay_id}</param>
</result>