`

nginx 和 tomcat 整合 window 环境

 
阅读更多

Nginx(发音同 engine x)是一款轻量级的Web 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器,并在一个BSD-like 协议下发行。由俄罗斯的程序设计师Igor Sysoev所开发,供俄国大型的入口网站及搜索引擎Rambler(俄文:Рамблер)使用。其特点是占有内存少,并发能力强,是目前市面上唯一能和kangleweb server比拼的web server,事实上nginx的并发能力确实在同类型的网页服务器中表现较好,中国大陆使用nginx网站用户有:新浪网易腾讯等。

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

    sendfile        on;
    #tcp_nopush     on;
	upstream 127.0.0.1 {  
		#根据ip计算将请求分配各那个后端tomcat,许多人误认为可以解决session问题,其实并不能。  
		#同一机器在多网情况下,路由切换,ip可能不同  
		#ip_hash;  
		#weigth参数表示权值,权值越高被分配到的几率越大  
	    server 127.0.0.1:8088 weight=1;  
	
	}  

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       80;
        server_name  localhost;#这是浏览器中访问的路径

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            #root   html\www;
			root	D:\\Workspaces\\cpzghtml;
            index  index.jsp index.html index.htm main.action; 
        }
		
		location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$              ###所以的静态文件人gif、jpg等都在本地打开,存放的目录为/usr/local/nginx/html,保存时间为30天  
		{  
			root         D:\\Workspaces\\cpzghtml;  ##这是一个动静页面分开的项目这里是静态项目路径
			expires      30d;  
		}
		
        location ~ (\.jsp)|(\.action)|(\.cl)$ {    #匹配以jsp结尾的,tomcat的网页文件是以jsp结尾         
                index   index.jsp;
                proxy_pass      http://127.0.0.1; #主要在这里,设置一个代理
        }
		
		  
		
		
        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # 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;
    #    }
    #}

}

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics