<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://www.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
    你下面的訪問速度快是因為有瀏覽器緩存
    主站蜘蛛池模板: 亚洲AV伊人久久青青草原| 国产亚洲老熟女视频| 污视频网站在线观看免费| 在线a亚洲v天堂网2018| 中文字幕av无码不卡免费| 亚洲电影中文字幕| 国产精品无码素人福利免费| 中文精品人人永久免费| 人妻无码久久一区二区三区免费| 国内精品久久久久影院亚洲| 亚洲区不卡顿区在线观看| 中文字幕无码播放免费| 亚洲国产免费综合| 亚洲va久久久久| 久久久久亚洲AV成人无码| 国产精品久免费的黄网站| 在线成人爽a毛片免费软件| 国产亚洲福利精品一区二区| 亚洲国产理论片在线播放| 亚洲成aⅴ人片久青草影院| 又粗又大又黑又长的免费视频| 青青操免费在线视频| 在线观看亚洲电影| 亚洲综合欧美色五月俺也去| 亚洲精品自产拍在线观看动漫| 亚洲乱码中文字幕综合234 | 阿v免费在线观看| 亚洲国产精品美女久久久久| 亚洲激情校园春色| 亚洲三级电影网址| 亚洲国产精品无码中文字| 精品国产人成亚洲区| 亚洲中文字幕无码爆乳av中文| 日本人的色道www免费一区| 好男人视频在线观看免费看片| 亚洲免费在线视频播放| 91精品全国免费观看含羞草| 免费在线观影网站| 一级特黄aa毛片免费观看| 中文字幕免费在线看线人| 九九精品免费视频|