Gzip没有在nginx CentOS上工作,尽管配置启用它 - 空宝网


Gzip没有在nginx CentOS上工作,尽管配置启用它

网站管理员 本文已被59人看过 本文被 0次点赞

gzip命令需要直接在http块中,而不是在服务器块中

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

events {
worker_connections 1024;
}

http {
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 /var/log/nginx/access.log main;

sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;

server_tokens off;

include /etc/nginx/mime.types;
default_type application/octet-stream;

limit_conn_zone $binary_remote_addr zone=addr:8m;
limit_req_zone $binary_remote_addr zone=mylimit:16m rate=16r/s;

gzip on;
gzip_vary on;
gzip_min_length 1024;
gzip_types text/css text/plain;
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name abcj.me;
root /srv;
index index-l1.html

client_body_timeout 8;
client_header_timeout 8;

location ~* \.(css|ico|jpeg|jpg|js|mp3|mp4|pdf|png|txt|webp|zip)$ {
expires 16d;
}

location ~* \.(html)$ {
expires 1d;
}

error_page 404 /404-l1.html;
location = /40x.html {
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}

server {
listen 80;
server_name http://www.abcj.me;
return 301 http://abcj.me$request_uri;
}
}

下一页:  如何在特定时间之间运行BackgroundTask?

喜欢 (0)
[请支持作者一杯咖啡,谢谢]
分享 (0)


您必须 登录 才能发表评论!