乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      Nginx的gzip壓縮

       JhouShuai 2015-01-08


      cat /usr/local/nginx/conf/nginx.conf

      user  www;
      worker_processes  2;

      #error_log  logs/error.log;
      #error_log  logs/error.log  notice;
      #error_log  logs/error.log  info;


      events {
          use epoll;
          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;
          client_max_body_size 20m;

          ####默認(rèn)情況下,Nginx的gzip壓縮是關(guān)閉的
          #gzip  on;

          server {
              listen       80;
              server_name  localhost;
              root html;
      index index.php index.html index.htm

              #charset koi8-r;

              #access_log  logs/host.access.log  main;

              #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$ {
                  fastcgi_pass   127.0.0.1:9000;
                  fastcgi_index  index.php;
                  fastcgi_param  SCRIPT_FILENAME  $document_root$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;
              #}
          }

          server {
            listen       80;
            server_name  hipigo.51.local;
            root   /home/www/hipigo.cn/1.5.1/public;
            index  index.html index.htm index.php;

            charset utf-8;
            location ~ ^/(images|javascript|js|css|flash|media|static)/  {      
              expires 30d; 
              log_not_found off;
            }
            
            # 設(shè)置不被防問的目錄
            location ~ ^/(application|library|var)/ {
              deny all;
            }
            
            #將request指向index.php
            location / {
              
              if (-f $request_filename) {
                break;
              }
              if (-d $request_filename) {
                break;
              }
              rewrite ^(.+)$ /index.php last;
            }
            
           
            #引用PHP CGI
            location ~ .*\.(php|php5)?$ {
                fastcgi_pass   127.0.0.1:9000;
                include fastcgi_params;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name; 
                fastcgi_read_timeout 600;
            }
          }

          server {
            listen       80;
            server_name  hipigo.53.local;
            root   /home/www/hipigo.cn/1.5.3/public;
            index  index.html index.htm index.php;

            charset utf-8;
            location ~ ^/(images|javascript|js|css|flash|media|static)/  {
              expires 30d;
              log_not_found off;
            }

            # 設(shè)置不被防問的目錄
            location ~ ^/(application|library|var)/ {
              deny all;
            }

            #將request指向index.php
            location / {

              if (-f $request_filename) {
                break;
              }
              if (-d $request_filename) {
                break;
              }
              rewrite ^(.+)$ /index.php last;
            }


            #引用PHP CGI
            location ~ .*\.(php|php5)?$ {
                fastcgi_pass   127.0.0.1:9000;
                include fastcgi_params;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                fastcgi_read_timeout 600;
            }
          }

          server {
            listen       80;
            server_name  hipigo.5.local;
            root   /home/www/hipigo.cn/1.5/public;
            index  index.html index.htm index.php;

            charset utf-8;
            location ~ ^/(images|javascript|js|css|flash|media|static)/  {      
              expires 30d; 
              log_not_found off;
            }
            
            # 設(shè)置不被防問的目錄
            location ~ ^/(application|library|var)/ {
              deny all;
            }
            
            #將request指向index.php
            location / {
              
              if (-f $request_filename) {
                break;
              }
              if (-d $request_filename) {
                break;
              }
              rewrite ^(.+)$ /index.php last;
            }
            
           
            #引用PHP CGI
            location ~ .*\.(php|php5)?$ {
                fastcgi_pass   127.0.0.1:9000;
                include fastcgi_params;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name; 
                fastcgi_read_timeout 600;
            }
          }


          server {
            listen       80;
            server_name  dev.2bi.net;
            root   /home/www/2bi/wwwroot/;
            index  index.php index.htm index.html;

            charset utf-8;
           
           location /admin/ {
             if (-f $request_filename) {
                break;
              }
              if (-d $request_filename) {
                break;
              }
              rewrite ^(.+)$ /admin/index.php last;
            }
           
           # 設(shè)置不被防問的目錄
           # location ~ ^/home/ {
           #   deny all;
           # }
           #零售官網(wǎng)首頁
           location /home/ {
             if (-f $request_filename) {
                break;
              }
              if (-d $request_filename) {
                break;
              }
              rewrite ^(.+)$ /home/index.php last;
            }

       
           location / {
              
              if (-f $request_filename) {
                  break;
              }
              if (-d $request_filename) {
                break;
              }
              rewrite ^(.+)$ /index.php last;
            }
            
           
            #引用PHP CGI
            location ~ .*\.(php|php5)?$ {
                fastcgi_pass   127.0.0.1:9000;
                include fastcgi_params;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name; 
                fastcgi_read_timeout 600;
            }
          }


         server {
            listen       80;
            server_name  pay.dev.hipigo.cn;
            root   /home/www/hipigo.cn/pay/wwwroot/;
            index  index.php index.htm index.html;

            charset utf-8;
            location / {

              if (-f $request_filename) {
                break;
              }
              if (-d $request_filename) {
                break;
              }
              rewrite ^(.+)$ /index.php last;
            }


            #引用PHP CGI
            location ~ .*\.(php|php5)?$ {
                fastcgi_pass   127.0.0.1:9000;
                include fastcgi_params;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                fastcgi_read_timeout 600;
            }
          }

          
         server {
            listen       80;
            server_name  dev.cmen.com;
            root   /home/www/cmen/wwwroot/;
            index  index.php index.htm index.html;

            charset utf-8;

           location /admin/ {
             if (-f $request_filename) {
                break;
              }
              if (-d $request_filename) {
                break;
              }
              rewrite ^(.+)$ /admin/index.php last;
            }

           # 設(shè)置不被防問的目錄
           # location ~ ^/home/ {
           #   deny all;
           # }
           #官網(wǎng)首頁
           location /home/ {
             if (-f $request_filename) {
                break;
              }
              if (-d $request_filename) {
                break;
              }
              rewrite ^(.+)$ /home/index.php last;
            }


           location / {

              if (-f $request_filename) {
                  break;
              }
              if (-d $request_filename) {
                break;
              }
              rewrite ^(.+)$ /index.php last;
            }

            #引用PHP CGI
            location ~ .*\.(php|php5)?$ {
                fastcgi_pass   127.0.0.1:9000;
                include fastcgi_params;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                fastcgi_read_timeout 600;
            }
          }





          server {
            listen       80;
            server_name  wx.dev.hipigo.cn;
            root   /home/www/hipigo.cn/2.0/trunck/wwwroot;
            index  index.php index.htm index.html;

            charset utf-8;
          
            location /biz {

              if (-f $request_filename) {
                break;
              }
              if (-d $request_filename) {
                break;
              }
              rewrite ^(.+)$ /biz/index.php last;
            }

            location /wapi {

              if (-f $request_filename) {
                break;
              }
              if (-d $request_filename) {
                break;
              }
              rewrite ^(.+)$ /wapi/index.php last;
            }
      location / {
              if (-f $request_filename) {
      expires  max;
                break;
              }
      if (!-e $request_filename){
      rewrite ^/(.*)$ /index.php last;
      }
      }     
           
      #引用PHP CGI
      location ~ .*\.(php|php5)?$ {
      fastcgi_pass   127.0.0.1:9000;
      include fastcgi_params;
      fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name; 
      fastcgi_read_timeout 600;
      }
      }

          server {
            listen       80;
            server_name  manage.dev.xrenwu.com;
            root   /home/www/it008.com.xrenwu/manage/public;
            index  index.php index.htm index.html;

            charset utf-8;
            location / {

              if (-f $request_filename) {
                break;
              }
              if (-d $request_filename) {
                break;
              }
              rewrite ^(.+)$ /index.php last;
            }


            #引用PHP CGI
            location ~ .*\.(php|php5)?$ {
                fastcgi_pass   127.0.0.1:9000;
                include fastcgi_params;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                fastcgi_read_timeout 600;
            }
         }

         server {
            listen       80;
            server_name  api.dev.xrenwu.com;
            root   /home/www/it008.com.xrenwu/service/public;
            index  index.php index.htm index.html;

            charset utf-8;
            location / {
              rewrite ^(.+)$ /index.php last;
            }


            #引用PHP CGI
            location ~ .*\.(php|php5)?$ {
                fastcgi_pass   127.0.0.1:9000;
                include fastcgi_params;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                fastcgi_read_timeout 600;
            }
         }

         server {
            listen       80;
            server_name  dev.xrenwu.com;
            root   /home/www/it008.com.xrenwu/website/public;
            index  index.php index.htm index.html;

            charset utf-8;
            location / {

              if (-f $request_filename) {
                break;
              }
              if (-d $request_filename) {
                break;
              }
              rewrite ^(.+)$ /index.php last;
            }


            #引用PHP CGI
            location ~ .*\.(php|php5)?$ {
                fastcgi_pass   127.0.0.1:9000;
                include fastcgi_params;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                fastcgi_read_timeout 600;
            }
         }
          server {
            listen       80;
            server_name  att.it008.com;
            root   /home/www/hipigo.cn/att;
            index  index.php index.htm index.html;

            charset utf-8;
            location / {
              
              if (-f $request_filename) {
                break;
              }
              if (-d $request_filename) {
                break;
              }
              rewrite ^(.+)$ /index.php last;
            }
            
           
            #引用PHP CGI
            location ~ .*\.(php|php5)?$ {
                fastcgi_pass   127.0.0.1:9000;
                include fastcgi_params;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name; 
                fastcgi_read_timeout 600;
          }
         }
      }

      以下內(nèi)容來自:

      默認(rèn)情況下,Nginx的gzip壓縮是關(guān)閉的, gzip壓縮功能就是可以讓你節(jié)省不少帶寬,但是會(huì)增加服務(wù)器CPU的開銷哦,Nginx默認(rèn)只對(duì)text/html進(jìn)行壓縮 ,如果要對(duì)html之外的內(nèi)容進(jìn)行壓縮傳輸,我們需要手動(dòng)來調(diào)。

      開啟gzip的指令如下:

       代碼如下復(fù)制代碼

      gzip on;
      gzip_http_version 1.0;
      gzip_disable "MSIE [1-6].";
      gzip_types text/plain application/x-javascript text/css text/javascript;

      關(guān)于gzip_types,如果你想讓圖片也開啟gzip壓縮,那么用以下這段吧:

      gzip_types text/plain application/x-javascript text/css text/javascript application/x-httpd-php image/jpeg image/gif image/png;

      網(wǎng)站開啟gzip壓縮,不僅能夠節(jié)省帶寬,也能夠快速響應(yīng)用戶的訪問,在nginx中,開啟gzip壓縮的方法為:
      gzip on;      (啟用 gzip 壓縮功能)

          gzip_proxied any;  (nginx 做前端代理時(shí)啟用該選項(xiàng),表示無論后端服務(wù)器的headers頭返回什么信息,都無條件啟用壓縮)

          gzip_min_length  1024; (最小壓縮的頁面,如果頁面過于小,可能會(huì)越壓越大,這里規(guī)定大于1K的頁面才啟用壓縮)

          gzip_buffers     4 8k; (設(shè)置系統(tǒng)獲取幾個(gè)單位的緩存用于存儲(chǔ)gzip的壓縮結(jié)果數(shù)據(jù)流)

          gzip_comp_level 3; (壓縮級(jí)別,1壓縮比最小處理速度最快,9壓縮比最大但處理最慢,同時(shí)也最消耗CPU,一般設(shè)置為3就可以了)

          gzip_types       text/plain text/css application/x-javascript application/javascript application/xml; (什么類型的頁面或文檔啟用壓縮)


      注意:

      1. 其中的gzip_http_version的設(shè)置,它的默認(rèn)值是1.1,就是說對(duì)HTTP/1.1協(xié)議的請(qǐng)求才會(huì)進(jìn)行g(shù)zip壓縮
      如果我們使用了proxy_pass進(jìn)行反向代理,那么nginx和后端的upstream server之間是用HTTP/1.0協(xié)議通信的
      This module makes it possible to transfer requests to another server.
      It is an HTTP/1.0 proxy without the ability for keep-alive requests yet. (As a result, backend connections are created and destroyed on every request.) Nginx talks HTTP/1.1 to the browser and HTTP/1.0 to the backend server. As such it handles keep-alive to the browser.
      如果我們使用nginx通過反向代理做Cache Server,而且前端的nginx沒有開啟gzip
      同時(shí),我們后端的nginx上沒有設(shè)置gzip_http_version為1.0,那么Cache的url將不會(huì)進(jìn)行g(shù)zip壓縮
       
      2. gzip_disable的設(shè)置是禁用IE6的gzip壓縮,又是因?yàn)楸叩腎E6
      IE6的某些版本對(duì)gzip的壓縮支持很不好,會(huì)造成頁面的假死,今天產(chǎn)品的同學(xué)就測(cè)試出了這個(gè)問題
      后來調(diào)試后,發(fā)現(xiàn)是對(duì)img進(jìn)行g(shù)zip后造成IE6的假死,把對(duì)img的gzip壓縮去掉后就正常了
      為了確保其它的IE6版本不出問題,所以就加上了gzip_disable的設(shè)置


        本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評(píng)論

        發(fā)表

        請(qǐng)遵守用戶 評(píng)論公約

        類似文章 更多