Nginx
nginx 上的神秘 gzip 故障
· gzip 在我的網站上顯示為未啟用
· 甚至我的主機 asmallorange 的技術支持都無法找出我的問題的原因
· 希望這裡有人可以
· 我已經記錄了我的確切設置(僅此而已)
1)我安裝了centos 7最小
2)我通過膩子登錄
3)然後我輸入以下命令
3a) 百勝更新
3b) 百勝清潔所有
3c) yum install epel-release
3d) 百勝安裝 nginx
3e) systemctl 啟用 nginx
3f) vi /etc/nginx/nginx.conf
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; server { listen 80 default_server; listen [::]:80 default_server; server_name abcj.me; root /srv; index index-l1.html gzip on; gzip_vary on; gzip_min_length 1024; gzip_types text/css text/plain; 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 www.abcj.me; return 301 http://abcj.me$request_uri; } }
3g) 服務 nginx 重啟
- 我通過 winscp 將 index-l1.html 上傳到 srv
· nginx -V 2>&1 | tr – - ‘\n’ | grep 模組
· 表明我有
·· http_gzip_static_module
·· http_gunzip_module
· curl -H “Accept-Encoding: gzip” -I http://abcj.me/index-l1.html
··不顯示gzip接受
· https://www.giftofspeed.com/gzip-test/
··不顯示gzip接受
· 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 www.abcj.me; return 301 http://abcj.me$request_uri; } }