??xml version="1.0" encoding="utf-8" standalone="yes"?>欧美精品一区二区三区在线,思热99re视热频这里只精品,亚洲三级精品http://www.aygfsteel.com/stevenjohn/category/53185.html那些青春的岁?/description>zh-cnFri, 04 Sep 2015 21:59:10 GMTFri, 04 Sep 2015 21:59:10 GMT60nginx 虚拟L讄http://www.aygfsteel.com/stevenjohn/archive/2015/08/29/427033.htmlabinabinSat, 29 Aug 2015 07:15:00 GMThttp://www.aygfsteel.com/stevenjohn/archive/2015/08/29/427033.htmlhttp://www.aygfsteel.com/stevenjohn/comments/427033.htmlhttp://www.aygfsteel.com/stevenjohn/archive/2015/08/29/427033.html#Feedback0http://www.aygfsteel.com/stevenjohn/comments/commentRss/427033.htmlhttp://www.aygfsteel.com/stevenjohn/services/trackbacks/427033.html
nginx配置文g目录QD:\Sys\server\nginx\nginx-1.9.4\conf
nginx.conf 配置文g如下Q?br />
#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  main;
    sendfile        on;
    #tcp_nopush     on;
    #keepalive_timeout  0;
    keepalive_timeout  65;
    #gzip  on;
    include vhosts/*.conf;
}

q个ȝ录只保留基本配置
 include vhosts/*.conf;q句话就是引用虚拟主机目录的配置文g

在该目录下面创徏vhosts目录Q?br />
D:\Sys\server\nginx\nginx-1.9.4\conf\vhosts
虚拟L(实际里面是配置upstream和serverQ然后server里面配置监听端口和serverNameQ还有location)目录里面的配|文件分别ؓQ?br />www.abin.com.conf
www.lee.com.conf

www.abin.com.conf的配|ؓQ?br />
upstream abin {
server localhost:9200 weight=10;
}
# another virtual host using mix of IP-, name-, and port-based configuration
server {
listen       8000;
server_name  www.abin.com abin.com;
location / {
   #反向代理的地址
            proxy_pass http://abin;
   root   html;
   index  index.html index.htm;
}
location /abin {
   #反向代理的地址
            proxy_pass http://abin;
   root   html;
   index  index.html index.htm;
}
}
www.lee.com.conf的配|ؓQ?/div>
upstream lee {
server localhost:9300 weight=10;//q个配置为tomcat的请求地址
}
# another virtual host using mix of IP-, name-, and port-based configuration
server {
listen       8000;
server_name  www.lee.com lee.com;
location / {
   #反向代理的地址
            proxy_pass http://lee;
   root   html;
   index  index.html index.htm;
}
location /abin {
   #反向代理的地址
            proxy_pass http://lee;
   root   html;
   index  index.html index.htm;
}
}



试Q?br />
http://www.lee.com:8000/
http://www.lee.com:8000/abin
http://lee.com:8000/abin
http://www.lee.com:8000/
http://www.lee.com:8000/lee
http://lee.com:8000/lee

我的tomcat服务器的web.xml都配|了<webcome-list>index.html</welcome-list>,
tomcat:9200配置了abinq个java工程Q它里面的index.html内容为helloQabin
tomcat:9300配置了abinq个java工程Q它里面的index.html内容为helloQlee

那么上面的第二个地址打印helloQabin
那么上面的第四个地址打印helloQlee


本地hosts文g配置为:
127.0.0.1       localhost 
127.0.0.1       www.abin.com     abin.com 
127.0.0.1       www.lee.com       lee.com 


abin 2015-08-29 15:15 发表评论
]]>nginx.conf的完整配|说?/title><link>http://www.aygfsteel.com/stevenjohn/archive/2013/01/03/393710.html</link><dc:creator>abin</dc:creator><author>abin</author><pubDate>Thu, 03 Jan 2013 06:52:00 GMT</pubDate><guid>http://www.aygfsteel.com/stevenjohn/archive/2013/01/03/393710.html</guid><wfw:comment>http://www.aygfsteel.com/stevenjohn/comments/393710.html</wfw:comment><comments>http://www.aygfsteel.com/stevenjohn/archive/2013/01/03/393710.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/stevenjohn/comments/commentRss/393710.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/stevenjohn/services/trackbacks/393710.html</trackback:ping><description><![CDATA[<p>Nginx配置文g详细说明<br />在此记录下Nginx服务器nginx.conf的配|文件说? 部分注释攉与网l?<br />#q行用户<br />user www-data;    <br />#启动q程,通常讄成和cpu的数量相{?br />worker_processes  1;<br />#全局错误日志及PID文g<br />error_log  /var/log/nginx/error.log;<br />pid        /var/run/nginx.pid;<br />#工作模式及连接数上限<br />events {<br />    use   epoll;             #epoll是多路复用IO(I/O Multiplexing)中的一U方?但是仅用于linux2.6以上内核,可以大大提高nginx的性能<br />    worker_connections  1024;#单个后台worker processq程的最大ƈ发链接数<br />    # multi_accept on; <br />}<br />#讑֮http服务器,利用它的反向代理功能提供负蝲均衡支持<br />http {<br />     #讑֮mimecd,cd由mime.type文g定义<br />    include       /etc/nginx/mime.types;<br />    default_type  application/octet-stream;<br />    #讑֮日志格式<br />    access_log    /var/log/nginx/access.log;<br />    #sendfile 指o指定 nginx 是否调用 sendfile 函数Qzero copy 方式Q来输出文gQ对于普通应用,<br />    #必须设ؓ on,如果用来q行下蝲{应用磁盘I(y)O重负载应用,可设|ؓ offQ以q盘与网lI/O处理速度Q降低系l的uptime.<br />    sendfile        on;<br />    #tcp_nopush     on;<br />   <br />    #q接时旉<br />    #keepalive_timeout  0;<br />    keepalive_timeout  65;<br />    tcp_nodelay        on;<br />    <br />    #开启gzip压羃<br />    gzip  on;<br />    gzip_disable "MSIE [1-6]\.(?!.*SV1)";<br />    #讑֮h~冲<br />    client_header_buffer_size    1k;<br />    large_client_header_buffers  4 4k;<br />    include /etc/nginx/conf.d/*.conf;<br />    include /etc/nginx/sites-enabled/*;<br />   <br />   #讑֮负蝲均衡的服务器列表<br />     upstream mysvr {<br />    #weigth参数表示权|权D高被分配到的几率大<br />    #本机上的Squid开?128端口<br />    server 192.168.8.1:3128 weight=5;<br />    server 192.168.8.2:80  weight=1;<br />    server 192.168.8.3:80  weight=6;<br />    }</p> <p>   server {<br />    #侦听80端口<br />        listen       80;<br />        #定义使用<a >www.xx.com</a>讉K<br />        server_name  <a >www.xx.com</a>;<br />        #讑֮本虚拟主机的讉K日志<br />        access_log  logs/www.xx.com.access.log  main;<br />    #默认h<br />    location / {<br />          root   /root;      #定义服务器的默认|站根目录位|?br />          index index.php index.html index.htm;   #定义首页索引文g的名U?br />          fastcgi_pass  <a >www.xx.com</a>;<br />         fastcgi_param  SCRIPT_FILENAME  $document_root/$fastcgi_script_name; <br />          include /etc/nginx/fastcgi_params;<br />        }<br />    # 定义错误提示面<br />    error_page   500 502 503 504 /50x.html;  <br />        location = /50x.html {<br />        root   /root;<br />    }<br />    #静态文Ӟnginx自己处理<br />    location ~ ^/(images|javascript|js|css|flash|media|static)/ {<br />        root /var/www/virtual/htdocs;<br />        #q期30天,静态文件不怎么更新Q过期可以设大一点,如果频繁更新Q则可以讄得小一炏V?br />        expires 30d;<br />    }<br />    #PHP 脚本h全部转发?FastCGI处理. 使用FastCGI默认配置.<br />    location ~ \.php$ {<br />        root /root;<br />        fastcgi_pass 127.0.0.1:9000;<br />        fastcgi_index index.php;<br />        fastcgi_param SCRIPT_FILENAME /home/www/www$fastcgi_script_name;<br />        include fastcgi_params;<br />    }<br />    #讑֮查看Nginx状态的地址<br />    location /NginxStatus {<br />        stub_status            on;<br />        access_log              on;<br />        auth_basic              "NginxStatus";<br />        auth_basic_user_file  conf/htpasswd;<br />    }<br />    #止讉K .htxxx 文g<br />    location ~ /\.ht {<br />        deny all;<br />    }<br />     <br />     }<br />}</p> <p><br />#以上是一些基本的配置,使用Nginx最大的好处是负蝲均衡<br />#如果要用负载均衡的?可以修改配置http节点如下Q?br />#讑֮http服务器,利用它的反向代理功能提供负蝲均衡支持<br />http {<br />     #讑֮mimecd,cd由mime.type文g定义<br />    include       /etc/nginx/mime.types;<br />    default_type  application/octet-stream;<br />    #讑֮日志格式<br />    access_log    /var/log/nginx/access.log;<br />    #省略上文有的一些配|节?br />    #。。。。。。。。。?br />    #讑֮负蝲均衡的服务器列表<br />     upstream mysvr {<br />    #weigth参数表示权|权D高被分配到的几率大<br />    server 192.168.8.1x:3128 weight=5;#本机上的Squid开?128端口<br />    server 192.168.8.2x:80  weight=1;<br />    server 192.168.8.3x:80  weight=6;<br />    }<br />   upstream mysvr2 {<br />    #weigth参数表示权|权D高被分配到的几率大<br />    server 192.168.8.x:80  weight=1;<br />    server 192.168.8.x:80  weight=6;<br />    }<br />   #W一个虚拟服务器<br />   server {<br />    #侦听192.168.8.x?0端口<br />        listen       80;<br />        server_name  192.168.8.x;<br />      #对aspx后缀的进行负载均衡请?br />    location ~ .*\.aspx$ {<br />         root   /root;      #定义服务器的默认|站根目录位|?br />          index index.php index.html index.htm;   #定义首页索引文g的名U?br />          proxy_pass  <a href="http://mysvr">http://mysvr</a> ;#h转向mysvr 定义的服务器列表<br />          #以下是一些反向代理的配置可删?<br />          proxy_redirect off;<br />         <br />   #后端的Web服务器可以通过X-Forwarded-For获取用户真实IP<br />          proxy_set_header Host $host;<br />          proxy_set_header X-Real-IP $remote_addr;<br />          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;<br />          client_max_body_size 10m;    #允许客户端请求的最大单文g字节?br />          client_body_buffer_size 128k;  #~冲Z理缓冲用Lh的最大字节数Q?br />          proxy_connect_timeout 90;  #nginx跟后端服务器q接时旉(代理q接时)<br />          proxy_send_timeout 90;        #后端服务器数据回传时?代理发送超?<br />          proxy_read_timeout 90;         #q接成功后,后端服务器响应时?代理接收时)<br />          proxy_buffer_size 4k;             #讄代理服务器(nginxQ保存用户头信息的缓冲区大小<br />          proxy_buffers 4 32k;               #proxy_buffers~冲区,|页q_?2k以下的话Q这栯|?br />          proxy_busy_buffers_size 64k;    #高负荷下~冲大小Qproxy_buffers*2Q?br />          proxy_temp_file_write_size 64k;  #讑֮~存文g夹大,大于q个|从upstream服务器传<br />       }<br />     }<br />}<br /></p><img src ="http://www.aygfsteel.com/stevenjohn/aggbug/393710.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/stevenjohn/" target="_blank">abin</a> 2013-01-03 14:52 <a href="http://www.aygfsteel.com/stevenjohn/archive/2013/01/03/393710.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Nginx+tomcat配置集群http://www.aygfsteel.com/stevenjohn/archive/2013/01/03/393709.htmlabinabinThu, 03 Jan 2013 06:51:00 GMThttp://www.aygfsteel.com/stevenjohn/archive/2013/01/03/393709.htmlhttp://www.aygfsteel.com/stevenjohn/comments/393709.htmlhttp://www.aygfsteel.com/stevenjohn/archive/2013/01/03/393709.html#Feedback0http://www.aygfsteel.com/stevenjohn/comments/commentRss/393709.htmlhttp://www.aygfsteel.com/stevenjohn/services/trackbacks/393709.html 开发的应用采用F5负蝲均衡交换机,F5请求{发给5台hp unix服务器,每台服务器有多个webserver实例Q对外提供web服务和socket{接口服务。之初,曾有个小的疑问Z不采用开源的apache、Nginx软g负蝲QF5讑֤动辄几十万,h昂贵Q自׃个比较幼E的问题Q后l明白:F5是操作于IOS|络模型的传输层QNginx、apache是基于http反向代理方式Q位于ISO模型的第七层应用层。直白些是TCP UDP 和http协议的区别,Nginx不能为基于TCP协议的应用提供负载均衡?/p>


      了解了二者之间的区别于应用场景,对Nginx产生厚的兴,阅读张宴?lt;实战Nginx>Q这?5q的伙子年L为M?妒忌Q,搞明白了大致原理和配|,Ubuntu10.10Qwindow下对Nginx+tomcat负蝲均衡做了配置试Q将全部h转发到tomcatQƈ未做静态,动态分开Q图片防盗链{配|?br />Nginx 介绍


     Nginx Q发韛_ engine xQ是一ƾ轻量的Web 服务器/反向代理服务器及?sh)子邮gQIMAP/POP3Q代理服务器Qƈ在一个BSD-like 协议下发行?nbsp; 其特Ҏ(gu)占有内存,q发能力强,事实上nginx的ƈ发能力确实在同类型的|页伺服器中表现较好.目前中国大陆使用nginx|站用户有:新浪、网易?腾讯,另外知名的微|志Plurk也用nginx?/p>


    上面的全是Nginx介绍基本上是废话Q下面{入正题,图文l合展示基本配置Q首先是window环境、其ơ是Ubuntu环境QVbox虚拟Q。本文主要基于Nginx下配|两台tomcatQ结构如下图Q?br />
 

Window xp环境QNginx+Tomcat6

1、下载地址

       http://nginx.org/en/download.html Q这里我们推荐下载稳定版Qstable versionsQ,本文采用nginx-0.8.20?/p>


2、目录结?/strong>


      Nginx-

               |_  conf   配置目录

               |_  contrib

               |_  docs 文档目录

               |_  logs  日志目录

               |_  temp 临时文g目录

               |_  html 静态页面目?/p>

               |_  nginx.exe ȝ?/p>


      window下安装Nginx极其单,解压~到一个无I格的英文目录即可(个h习惯Q担心中文出问题Q,双击nginx启动Q这里我安装刎ͼD:\server目录Q下面涉及到的tomcat也安装在此目录?/p>

   

DOS环境启动

 

若果惛_止nginxQdos环境q行命oQnginx -s stop


3、nginx.conf配置


   Nginx配置文g默认在conf目录Q主要配|文件ؓnginx.confQ我们安装在D:\server\nginx-0.8.20、默认主配置文g为D:\server\nginx-0.8.20\nginx.conf。下面是nginx作ؓ前端反向代理服务器的配置?/p>

#Nginx所用用户和l,window下不指定
#user  niumd niumd;
#工作的子q程数量Q通常{于CPU数量或?倍于CPUQ?
worker_processes  2;
#错误日志存放路径
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
error_log  logs/error.log  info;
#指定pid存放文g
pid        logs/nginx.pid;
events {
#使用|络IO模型linuxepollQFreeBSD采用kqueueQwindow下不指定?
#use epoll;
#允许最大连接数
worker_connections  2048;
}
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  off;
access_log  logs/access.log;
client_header_timeout  3m;
client_body_timeout    3m;
send_timeout           3m;
client_header_buffer_size    1k;
large_client_header_buffers  4 4k;
sendfile        on;
tcp_nopush      on;
tcp_nodelay     on;
#keepalive_timeout  75 20;
include    gzip.conf;
upstream localhost {
#Ҏ(gu)ip计算请求分配各那个后端tomcatQ许多h误认为可以解决session问题Q其实ƈ不能?
#同一机器在多|情况下Q\由切换,ip可能不同
#ip_hash;
server localhost:18081;
server localhost:18080;
}
server {
listen       80;
server_name  localhost;
location / {
proxy_connect_timeout   3;
proxy_send_timeout      30;
proxy_read_timeout      30;
proxy_pass http://localhost;
}
}
}

 
   代理讄如下Q?/p>

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;
client_max_body_size    10m;
client_body_buffer_size 128k;
proxy_connect_timeout   300;
proxy_send_timeout      300;
proxy_read_timeout      300;
proxy_buffer_size       4k;
proxy_buffers           4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;


   gzip压羃相关配置如下Q?/p>

gzip              on;
gzip_min_length      1000;
gzip_types         text/plain text/css application/x-javascript;

 
  4、Tomcat配置


   对于tomcat大家都很熟?zhn)Q只需要修改server.xml配置文g卛_Q这里我们以apache-tomcat-6.0.14ZQ分别在server目录Q解压羃q命名ؓQapache-tomcat-6.0.14_1、apache-tomcat-6.0.14_2?/p>


    W一处端口修改:

<!--  修改port端口Q?8006 俩个tomcat不能重复Q端口随意,别太?->
<Server port="18006" shutdown="SHUTDOWN">

 
   W二处端口修改:

<!-- port="18081" tomcat监听端口Q随意设|,别太?-->
<Connector port="18081" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
 


   W三处端口修改:

<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />


   Engine元素增加jvmRoute属性:

<Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat1">

 
    两个tomcat的端口别重复Q保证能启动hQ另一个tomcat配置希捷省略Q监听端口ؓ18080Q附件中我们上传所有的配置信息?/p>


5、验证配|与试负蝲均衡


    首先试nginx配置是否正确Q测试命令:nginx -t  (默认验证:conf\nginx.conf),也可以指定配|文件\径?/p>

 此例nginx安装目录QD:\server\nginx-0.8.20Qdos环境下图画面成功CZQ?br />

   其次验证tomcatQ启动两个tomcatQ不出现端口冲突即ؓ成功Qtomcat依赖的java{搞“挨踢”的就废话不说了)Q?/p>

 

    最后验证配|负载均衡设|,http://localhost/ ?a style="background-color: transparent; color: rgb(102,102,102)" href="http://localhost/index.jsp" mce_href="http://localhost/index.jsp">http://localhost/index.jsp 。我修改了index.jsp面Q增加日志输Z息,便于观察。注意:左上角小猫头上的Qaccess tomcat2、access tomcat1。说明访问了不同的tomcat?/p>

  

 
     xwindow下nginx+tomcat负蝲均衡配置l束Q关于tomcat Session的问题通常是采用memcachedQ或者采用nginx_upstream_jvm_route Q他是一?Nginx 的扩展模块,用来实现Z Cookie ?Session Sticky 的功能。如果tomcatq多不徏议session同步Qserver间相互同步session很耗资源,高ƈ发环境容易引起Session风暴。请Ҏ(gu)自己应用情况合理采纳session解决Ҏ(gu)?/p>



 作者:niumd 

  Blog:http://ari.iteye.com



abin 2013-01-03 14:51 发表评论
]]>
nginx tomcathttp://www.aygfsteel.com/stevenjohn/archive/2013/01/03/393708.htmlabinabinThu, 03 Jan 2013 06:47:00 GMThttp://www.aygfsteel.com/stevenjohn/archive/2013/01/03/393708.htmlhttp://www.aygfsteel.com/stevenjohn/comments/393708.htmlhttp://www.aygfsteel.com/stevenjohn/archive/2013/01/03/393708.html#Feedback0http://www.aygfsteel.com/stevenjohn/comments/commentRss/393708.htmlhttp://www.aygfsteel.com/stevenjohn/services/trackbacks/393708.html//nginx.conf


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

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;
    include    gzip.conf; 
    upstream localhost { 
      #Ҏ(gu)ip计算请求分配各那个后端tomcatQ许多h误认为可以解决session问题Q其实ƈ不能?nbsp;
      #同一机器在多|情况下Q\由切换,ip可能不同 
      #ip_hash;  
      server localhost:16300  weight=5; 
      server localhost:16400  weight=1; 
     } 

    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
      proxy_connect_timeout   3; 
                    proxy_send_timeout      30; 
                    proxy_read_timeout      30; 
                    proxy_pass http://localhost
            root   html;
            index  index.html index.htm;
        }

        #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;
    #    server_name  localhost;

    #    ssl                  on;
    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

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

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}





//?NGINX_HOME%/conf/下面新增proxy.conf
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; 
client_max_body_size    10m; 
client_body_buffer_size 128k; 
proxy_connect_timeout   300; 
proxy_send_timeout      300; 
proxy_read_timeout      300; 
proxy_buffer_size       4k; 
proxy_buffers           4 32k; 
proxy_busy_buffers_size 64k; 
proxy_temp_file_write_size 64k;




//?NGINX_HOME%/conf/下面新增gzip.conf
gzip              on; 
gzip_min_length      1000; 
gzip_types         text/plain text/css application/x-javascript;





//tomcat63    %TOMCAT_HOME%/conf/server.xml

<?xml version='1.0' encoding='utf-8'?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<!-- Note:  A "Server" is not itself a "Container", so you may not
     define subcomponents such as "Valves" at this level.
     Documentation at /docs/config/server.html
 -->
<Server port="16305" shutdown="SHUTDOWN">

  <!--APR library loader. Documentation at /docs/apr.html -->
  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
  <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
  <Listener className="org.apache.catalina.core.JasperListener" />
  <!-- Prevent memory leaks due to use of particular java/javax APIs-->
  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
  <!-- JMX Support for the Tomcat server. Documentation at /docs/non-existent.html -->
  <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />

  <!-- Global JNDI resources
       Documentation at /docs/jndi-resources-howto.html
  -->
  <GlobalNamingResources>
    <!-- Editable user database that can also be used by
         UserDatabaseRealm to authenticate users
    -->
    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
              description="User database that can be updated and saved"
              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
              pathname="conf/tomcat-users.xml" />
  </GlobalNamingResources>

  <!-- A "Service" is a collection of one or more "Connectors" that share
       a single "Container" Note:  A "Service" is not itself a "Container",
       so you may not define subcomponents such as "Valves" at this level.
       Documentation at /docs/config/service.html
   -->
  <Service name="Catalina">
 
    <!--The connectors can use a shared executor, you can define one or more named thread pools-->
    <!--
    <Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
        maxThreads="150" minSpareThreads="4"/>
    -->
   
   
    <!-- A "Connector" represents an endpoint by which requests are received
         and responses are returned. Documentation at :
         Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
         Java AJP  Connector: /docs/config/ajp.html
         APR (HTTP/AJP) Connector: /docs/apr.html
         Define a non-SSL HTTP/1.1 Connector on port 8080
    -->
    <Connector port="16300" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
    <!-- A "Connector" using the shared thread pool-->
    <!--
    <Connector executor="tomcatThreadPool"
               port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
    -->          
    <!-- Define a SSL HTTP/1.1 Connector on port 8443
         This connector uses the JSSE configuration, when using APR, the
         connector should be using the OpenSSL style configuration
         described in the APR documentation -->
    <!--
    <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
               maxThreads="150" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS" />
    -->

    <!-- Define an AJP 1.3 Connector on port 8009 -->
    <Connector port="16309" protocol="AJP/1.3" redirectPort="8443" />


    <!-- An Engine represents the entry point (within Catalina) that processes
         every request.  The Engine implementation for Tomcat stand alone
         analyzes the HTTP headers included with the request, and passes them
         on to the appropriate Host (virtual host).
         Documentation at /docs/config/engine.html -->

    <!-- You should set jvmRoute to support load-balancing via AJP ie :
    <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">        
    -->
    <Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat63">

      <!--For clustering, please take a look at documentation at:
          /docs/cluster-howto.html  (simple how to)
          /docs/config/cluster.html (reference documentation) -->
      <!--
      <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
      -->       

      <!-- The request dumper valve dumps useful debugging information about
           the request and response data received and sent by Tomcat.
           Documentation at: /docs/config/valve.html -->
      <!--
      <Valve className="org.apache.catalina.valves.RequestDumperValve"/>
      -->

      <!-- This Realm uses the UserDatabase configured in the global JNDI
           resources under the key "UserDatabase".  Any edits
           that are performed against this UserDatabase are immediately
           available for use by the Realm.  -->
      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
             resourceName="UserDatabase"/>

      <!-- Define the default virtual host
           Note: XML Schema validation will not work with Xerces 2.2.
       -->
      <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">

        <!-- SingleSignOn valve, share authentication between web applications
             Documentation at: /docs/config/valve.html -->
        <!--
        <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
        -->

        <!-- Access log processes all example.
             Documentation at: /docs/config/valve.html -->
        <!--
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" 
               prefix="localhost_access_log." suffix=".txt" pattern="common" resolveHosts="false"/>
        -->

      </Host>
    </Engine>
  </Service>
</Server>




%TOMCAT_HOME%/conf/server.xml

<?xml version='1.0' encoding='utf-8'?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<!-- Note:  A "Server" is not itself a "Container", so you may not
     define subcomponents such as "Valves" at this level.
     Documentation at /docs/config/server.html
 -->
<Server port="16405" shutdown="SHUTDOWN">

  <!--APR library loader. Documentation at /docs/apr.html -->
  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
  <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
  <Listener className="org.apache.catalina.core.JasperListener" />
  <!-- Prevent memory leaks due to use of particular java/javax APIs-->
  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
  <!-- JMX Support for the Tomcat server. Documentation at /docs/non-existent.html -->
  <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />

  <!-- Global JNDI resources
       Documentation at /docs/jndi-resources-howto.html
  -->
  <GlobalNamingResources>
    <!-- Editable user database that can also be used by
         UserDatabaseRealm to authenticate users
    -->
    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
              description="User database that can be updated and saved"
              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
              pathname="conf/tomcat-users.xml" />
  </GlobalNamingResources>

  <!-- A "Service" is a collection of one or more "Connectors" that share
       a single "Container" Note:  A "Service" is not itself a "Container",
       so you may not define subcomponents such as "Valves" at this level.
       Documentation at /docs/config/service.html
   -->
  <Service name="Catalina">
 
    <!--The connectors can use a shared executor, you can define one or more named thread pools-->
    <!--
    <Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
        maxThreads="150" minSpareThreads="4"/>
    -->
   
   
    <!-- A "Connector" represents an endpoint by which requests are received
         and responses are returned. Documentation at :
         Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
         Java AJP  Connector: /docs/config/ajp.html
         APR (HTTP/AJP) Connector: /docs/apr.html
         Define a non-SSL HTTP/1.1 Connector on port 8080
    -->
    <Connector port="16400" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
    <!-- A "Connector" using the shared thread pool-->
    <!--
    <Connector executor="tomcatThreadPool"
               port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
    -->          
    <!-- Define a SSL HTTP/1.1 Connector on port 8443
         This connector uses the JSSE configuration, when using APR, the
         connector should be using the OpenSSL style configuration
         described in the APR documentation -->
    <!--
    <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
               maxThreads="150" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS" />
    -->

    <!-- Define an AJP 1.3 Connector on port 8009 -->
    <Connector port="16409" protocol="AJP/1.3" redirectPort="8443" />


    <!-- An Engine represents the entry point (within Catalina) that processes
         every request.  The Engine implementation for Tomcat stand alone
         analyzes the HTTP headers included with the request, and passes them
         on to the appropriate Host (virtual host).
         Documentation at /docs/config/engine.html -->

    <!-- You should set jvmRoute to support load-balancing via AJP ie :
    <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">        
    -->
    <Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat64">

      <!--For clustering, please take a look at documentation at:
          /docs/cluster-howto.html  (simple how to)
          /docs/config/cluster.html (reference documentation) -->
      <!--
      <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
      -->       

      <!-- The request dumper valve dumps useful debugging information about
           the request and response data received and sent by Tomcat.
           Documentation at: /docs/config/valve.html -->
      <!--
      <Valve className="org.apache.catalina.valves.RequestDumperValve"/>
      -->

      <!-- This Realm uses the UserDatabase configured in the global JNDI
           resources under the key "UserDatabase".  Any edits
           that are performed against this UserDatabase are immediately
           available for use by the Realm.  -->
      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
             resourceName="UserDatabase"/>

      <!-- Define the default virtual host
           Note: XML Schema validation will not work with Xerces 2.2.
       -->
      <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">

        <!-- SingleSignOn valve, share authentication between web applications
             Documentation at: /docs/config/valve.html -->
        <!--
        <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
        -->

        <!-- Access log processes all example.
             Documentation at: /docs/config/valve.html -->
        <!--
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" 
               prefix="localhost_access_log." suffix=".txt" pattern="common" resolveHosts="false"/>
        -->

      </Host>
    </Engine>
  </Service>
</Server>





先启动nginxQ后启动tomcat?br />

首先试nginx配置是否正确Q测试命令:nginx -t  (默认验证:conf\nginx.conf),也可以指定配|文件\径?/p>

其次验证tomcatQ启动两个tomcatQ不出现端口冲突即ؓ成功Qtomcat依赖的java{搞“挨踢”的就废话不说了)Q?/p>


 



abin 2013-01-03 14:47 发表评论
]]>
վ֩ģ壺 ʤ| | | | | | | ͨ| | Ԫ| ױ| ¦| | | | | ƽ| | | ׷| | | ɽ| | | | º| ƽ| | ɼ| | е| | | ʡ| ʡ| | | | ͨ| |