<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 :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

    nginx和tomcat負載簡單配置(windows環境)

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

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

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

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

    一下是nginx的配置:


    Nginx.conf
    內容:

     

    #user nobody;

    worker_processes 
    2#進程數,和cpu個數相關

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

        sendfile        on;

        

        keepalive_timeout 
    65;

     

        include gzip
    .conf;#啟動數據壓縮

     

         

        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有寫是服務器動態生成的,不能交給nginx處理,這樣會出現404,需要單獨處理并交給服務器處理。

             location 
    /ndemo/dwr/ {    

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

                 include proxy
    .conf;

            }

    #其他的靜態文件處理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,默認跳轉到ndemo項目的路徑下,也就是跳轉到上面的路徑

            location 
    / {

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

            }

           location 
    ~ ^/NginxStatus {#nginx的狀態監控需要basic密碼保護,可使用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; 

     

    順便展示單獨使用tomcat和使用了nginxgzip的請求對照情況,可以明顯發現nginx對靜態文件的處理效率非常高。

     

    單獨使用tomcat

     

    使用nginxgzip壓縮后的請求情況

     


    評論

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

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

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

    2015-07-29 00:39 by alex
    你下面的訪問速度快是因為有瀏覽器緩存
    主站蜘蛛池模板: 91av免费在线视频| 亚洲精品无码久久久久去q | 亚洲免费视频网址| www免费插插视频| 亚洲AV永久无码精品一福利 | 久久久久国色AV免费观看性色 | 亚洲第一精品电影网| 亚洲线精品一区二区三区影音先锋| 麻豆国产精品入口免费观看| 国产精品69白浆在线观看免费| 99久久精品免费精品国产| 国产麻豆成人传媒免费观看| 一级毛片试看60分钟免费播放| 国产精品亚洲一区二区在线观看| 亚洲精品二三区伊人久久| 亚洲蜜芽在线精品一区| 亚洲情XO亚洲色XO无码| 国产精品亚洲mnbav网站| 亚洲av再在线观看| 免费a级毛片视频| 四虎国产精品免费久久影院| 日本一道本高清免费| 在线观看91精品国产不卡免费| 拍拍拍又黄又爽无挡视频免费| 免费精品国产日韩热久久| 国产a视频精品免费观看| 国产情侣激情在线视频免费看 | 亚洲最大黄色网址| 亚洲一卡2卡3卡4卡国产网站 | 最近中文字幕免费完整| 无码av免费网站| 最近2019中文字幕免费直播| 美女内射无套日韩免费播放| 99re在线这里只有精品免费| 中文字幕亚洲免费无线观看日本| www视频免费看| 国产福利在线免费| 国产精品美女自在线观看免费| 国产不卡免费视频| 国产精品亚洲精品日韩已方| 在线a亚洲v天堂网2019无码|