<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    瘋狂

    STANDING ON THE SHOULDERS OF GIANTS
    posts - 481, comments - 486, trackbacks - 0, articles - 1
      BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理

    nginx和tomcat負(fù)載簡單配置(windows環(huán)境)

    Posted on 2011-12-07 10:40 瘋狂 閱讀(6975) 評論(2)  編輯  收藏 所屬分類: java性能 、架構(gòu) 、nginx

    本文講了windows環(huán)境下的nginxtomcat的一個簡單的配置實例包括dwr的的js特殊的地方配置。當(dāng)然nginx只有才unix下才能表現(xiàn)出好的性能,主要是io模型等方面。
    關(guān)于linux下的配置可見于網(wǎng)上的這篇文章http://bbs.linuxtone.org/forum.php?mod=viewthread&tid=394
     項目demo的下載:/Files/freeman1984/ndemo.rar,里面包含了簡單的測試項目和配置文件,以及nginx的參考文檔一份。

    項目單獨(dú)在tomcat下訪問路徑為: http://localhost:8088/ndemo/server.jsp

    Nginx下訪問路徑:http://www.joe.com/server.jsp  ,其中(www.joe.com是我在hosts文件里面配置的

    一下是nginx的配置:


    Nginx.conf
    內(nèi)容:

     

    #user nobody;

    worker_processes 
    2#進(jìn)程數(shù),和cpu個數(shù)相關(guān)

    pid        logs
    /nginx.pid;

    events {

        worker_connections 
    1024;#每個進(jìn)程的支持的連接數(shù)

    }

     

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

        sendfile        on;

        

        keepalive_timeout 
    65;

     

        include gzip
    .conf;#啟動數(shù)據(jù)壓縮

     

         

        server {

            
    listen       80;

            server_name www
    .joe.com;#此部分測試的時候可以在host文件里面加上

            root   E
    :\apache-tomcat-6.0.32\webapps;#項目路徑,直接和后臺使用一個目錄

            error_page 
    404 /ndemo/404.html;

            error_page   
    500 502 503 504 /ndemo/50x.html;

           

            location 
    ~ ^/(WEB-INF)/ {

                deny all;

            }

            
    #此部分主要是dwr的js有寫是服務(wù)器動態(tài)生成的,不能交給nginx處理,這樣會出現(xiàn)404,需要單獨(dú)處理并交給服務(wù)器處理。

             location 
    /ndemo/dwr/ {    

                 proxy_pass http
    ://localhost:8088/ndemo/dwr/;

                 include proxy
    .conf;

            }

    #其他的靜態(tài)文件處理dwr的都交給nginx處理

            location 
    ~ \.


    (htm
    |html|gif|jpg|jpeg|png|ico|rar|css|js|zip|txt|flv|swf|doc|ppt|xls|pdf)$ {

                access_log off;

                expires 24h;

            }

           
    #注意我的上下文是ndemo

           location 
    /ndemo/ {

                 proxy_pass http
    ://localhost:8088/ndemo/;

                 include proxy
    .conf;

            }

            
    #訪問根目錄下的路徑也就是webapp,默認(rèn)跳轉(zhuǎn)到ndemo項目的路徑下,也就是跳轉(zhuǎn)到上面的路徑

            location 
    / {

                 rewrite (
    .*)$ /ndemo$1 permanent;

            }

           location 
    ~ ^/NginxStatus {#nginx的狀態(tài)監(jiān)控需要basic密碼保護(hù),可使用apache的工具生成,方式可見于http://m.tkk7.com/freeman1984/articles/363943.html}

                stub_status on;

                access_log off;

                auth_basic              
    "valid-user";

                auth_basic_user_file ewds_pw;

           }

        }

     

    }

     

    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;

     

    gzip.conf

     

    gzip            on;

    gzip_min_length     
    1024;

    gzip_types      text
    /plain text/css application/x-javascript; 

     

    順便展示單獨(dú)使用tomcat和使用了nginxgzip的請求對照情況,可以明顯發(fā)現(xiàn)nginx對靜態(tài)文件的處理效率非常高。

     

    單獨(dú)使用tomcat

     

    使用nginxgzip壓縮后的請求情況

     


    評論

    # re: nginx和tomcat負(fù)載簡單配置(windows環(huán)境)  回復(fù)  更多評論   

    2011-12-10 13:05 by tb
    不錯 好資料

    # re: nginx和tomcat負(fù)載簡單配置(windows環(huán)境)[未登錄]  回復(fù)  更多評論   

    2015-07-29 00:39 by alex
    你下面的訪問速度快是因為有瀏覽器緩存
    主站蜘蛛池模板: 亚洲白色白色永久观看| 国产成人亚洲精品狼色在线| 亚洲理论在线观看| 99视频在线精品免费| 久久精品国产亚洲av麻豆色欲| 中文字幕不卡免费视频| 国产亚洲综合成人91精品| 成人免费区一区二区三区 | 大香人蕉免费视频75| 亚洲自国产拍揄拍| 成人男女网18免费视频| 亚洲码欧美码一区二区三区| 热99re久久免费视精品频软件| 国产精品亚洲精品久久精品| www国产亚洲精品久久久| 五月天国产成人AV免费观看| 亚洲永久无码3D动漫一区| 在线涩涩免费观看国产精品| 亚洲无线电影官网| 国产免费AV片在线播放唯爱网| 亚洲精品无码成人片久久不卡| 国产免费一区二区三区VR| 新最免费影视大全在线播放| 国产亚洲色婷婷久久99精品| 中文字幕在线观看免费视频| 国产精品亚洲综合久久| 亚洲AV无码一区二三区 | 狠狠热精品免费观看| 中文字幕中韩乱码亚洲大片| 免费A级毛片无码A∨中文字幕下载| 亚洲日韩乱码中文无码蜜桃| 国产精品va无码免费麻豆| 成人免费视频一区二区| 亚洲最大福利视频网站| 妞干网手机免费视频| 成人妇女免费播放久久久| 亚洲一区二区三区国产精品无码| 又爽又高潮的BB视频免费看| 97在线视频免费播放| 99亚洲男女激情在线观看| 亚洲国产综合91精品麻豆|