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; ####默认情况下,Nginx的gzip压缩是关闭的 #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; } # 设置不被防问的目录 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; } # 设置不被防问的目录 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; } # 设置不被防问的目录 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; } # 设置不被防问的目录 # location ~ ^/home/ { # deny all; # } #零售官网首页 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; } # 设置不被防问的目录 # location ~ ^/home/ { # deny all; # } #官网首页 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; } } } 以下内容来自: 默认情况下,Nginx的gzip压缩是关闭的, gzip压缩功能就是可以让你节省不少带宽,但是会增加服务器CPU的开销哦,Nginx默认只对text/html进行压缩 ,如果要对html之外的内容进行压缩传输,我们需要手动来调。 开启gzip的指令如下:
关于gzip_types,如果你想让图片也开启gzip压缩,那么用以下这段吧: gzip_types text/plain application/x-javascript text/css text/javascript application/x-httpd-php image/jpeg image/gif image/png; 网站开启gzip压缩,不仅能够节省带宽,也能够快速响应用户的访问,在nginx中,开启gzip压缩的方法为: gzip_proxied any; (nginx 做前端代理时启用该选项,表示无论后端服务器的headers头返回什么信息,都无条件启用压缩) gzip_min_length 1024; (最小压缩的页面,如果页面过于小,可能会越压越大,这里规定大于1K的页面才启用压缩) gzip_buffers 4 8k; (设置系统获取几个单位的缓存用于存储gzip的压缩结果数据流) gzip_comp_level 3; (压缩级别,1压缩比最小处理速度最快,9压缩比最大但处理最慢,同时也最消耗CPU,一般设置为3就可以了) gzip_types text/plain text/css application/x-javascript application/javascript application/xml; (什么类型的页面或文档启用压缩)
1. 其中的gzip_http_version的设置,它的默认值是1.1,就是说对HTTP/1.1协议的请求才会进行gzip压缩 |
|