关于NGNIX配置 虚拟主机 出现的一点儿问题

四十大盗与阿里巴巴 发布于 2013/07/31 17:56
阅读 221
收藏 0

运行环境 centos6.3 64位操作系统

软件环境 nginx version: nginx/1.3.15  配置两个虚拟主机 代理到tomcat

问题如下:访问www.a.com可以正常按配置文件走到www.a.com/index.htm,在首页下www.a.com/index.htm下向en.a.com跳转则出现en.a.com/index.htm/,访问失败.正确情况下en.a.com/index.htm可以正确访问

不知道是什么原因,我觉得可能出现的问题在如下几行代码中,但是找不到原因,希望能得到指点

index  index.jsp index.html index.htm; 
rewrite ^/(.*)([^/])$ http://$host/$1$2/ permanent;

 

ngnix的配置如下:

user  nobody;
worker_processes  2;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

pid        /usr/local/nginx/nginx.pid;


events {
    worker_connections  1024;
}


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;
    tcp_nodelay on;

  	#gzip setting
  	gzip  on;
  	gzip_http_version 1.1;
  	gzip_vary on;
  	gzip_comp_level 6;
  	gzip_proxied any;
  	gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
  	gzip_buffers 16 8k;
  	# Disable gzip for certain browsers.
  	gzip_disable “MSIE [1-6].(?!.*SV1)”;

    server {
        listen 80 default_server;
        server_name  www.a.com
        #charset koi8-r; 
        access_log  /usr/local/nginx/logs/host.access.log;

        location / {
            root   /data/adirectory;
            index  index.jsp index.html index.htm;
	    	rewrite ^/(.*)([^/])$ http://$host/$1$2/ permanent;
			location ~ .*.(jsp|htm|action)$ {
				proxy_redirect off;
				proxy_set_header Host  $host;
				proxy_pass http://localhost:8080;
			}
	
			location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
			    expires 30d;
			}
			location ~ .*\.(js|css)?$ {
			    expires 1h;
			}
        }

        error_page   500 502 503 504  /50x.html;

        location = /50x.html {
            root   html;
        }
    }
	server {
		listen 80;
		server_name en.a.com
		location / {
			root   /data/adirectoryen;
            index  index.jsp index.html index.htm; 
	    	rewrite ^/(.*)([^/])$ http://$host/$1$2/ permanent;
			location ~ .*.(jsp|htm|action)$ {
				proxy_redirect off;
				proxy_set_header Host  $host;
				proxy_pass http://localhost:8080;
			}
	
			location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
			    expires 30d;
			}
			location ~ .*\.(js|css)?$ {
			    expires 1h;
			}
			
		}

		error_page   500 502 503 504  /50x.html;

        location = /50x.html {
            root   html;
        }
	}

}

 

以下是问题补充:

@四十大盗与阿里巴巴:奇怪之处在于 在谷歌浏览器及firefox浏览器下边 www.a.com en.a.com都正常 但是在IE系列浏览器下边,www.a.com正常 到en.a.com就出会现无法访问的情况,并且地址栏回写的路径为en.a.com/index.htm/ (2013/07/31 19:15)
加载中
0
iSea
iSea
为什么写这个rewrite呢,每次个地址后面都加了/,index.html/访问当然会出错了
四十大盗与阿里巴巴
四十大盗与阿里巴巴
我很奇怪为什么只有IE不好使啊.
返回顶部
顶部