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è)置不被防問(wèn)的目錄 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è)置不被防問(wèn)的目錄 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è)置不被防問(wèn)的目錄 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è)置不被防問(wèn)的目錄 # location ~ ^/home/ { # deny all; # } #零售官網(wǎng)首頁(yè) 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è)置不被防問(wèn)的目錄 # location ~ ^/home/ { # deny all; # } #官網(wǎng)首頁(yè) 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)容來(lái)自: 默認(rèn)情況下,Nginx的gzip壓縮是關(guān)閉的, gzip壓縮功能就是可以讓你節(jié)省不少帶寬,但是會(huì)增加服務(wù)器CPU的開(kāi)銷(xiāo)哦,Nginx默認(rèn)只對(duì)text/html進(jìn)行壓縮 ,如果要對(duì)html之外的內(nèi)容進(jìn)行壓縮傳輸,我們需要手動(dòng)來(lái)調(diào)。 開(kāi)啟gzip的指令如下:
關(guān)于gzip_types,如果你想讓圖片也開(kāi)啟gzip壓縮,那么用以下這段吧: gzip_types text/plain application/x-javascript text/css text/javascript application/x-httpd-php image/jpeg image/gif image/png; 網(wǎng)站開(kāi)啟gzip壓縮,不僅能夠節(jié)省帶寬,也能夠快速響應(yīng)用戶的訪問(wèn),在nginx中,開(kāi)啟gzip壓縮的方法為: gzip_proxied any; (nginx 做前端代理時(shí)啟用該選項(xiàng),表示無(wú)論后端服務(wù)器的headers頭返回什么信息,都無(wú)條件啟用壓縮) gzip_min_length 1024; (最小壓縮的頁(yè)面,如果頁(yè)面過(guò)于小,可能會(huì)越壓越大,這里規(guī)定大于1K的頁(yè)面才啟用壓縮) 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; (什么類(lèi)型的頁(yè)面或文檔啟用壓縮)
1. 其中的gzip_http_version的設(shè)置,它的默認(rèn)值是1.1,就是說(shuō)對(duì)HTTP/1.1協(xié)議的請(qǐng)求才會(huì)進(jìn)行g(shù)zip壓縮 |
|