Skip to content

Instantly share code, notes, and snippets.

@anhdiepmmk
Created December 27, 2019 03:02
Show Gist options
  • Save anhdiepmmk/57bf09fac20284c1b1ef4761b87b5618 to your computer and use it in GitHub Desktop.
Save anhdiepmmk/57bf09fac20284c1b1ef4761b87b5618 to your computer and use it in GitHub Desktop.
Cấu hình nginx với module gzip bật để tối ưu tốc độ trả về của các file json, xml, css, plain text.
server {
listen 80;
server_name your.domain;
root /var/www/html/;
index index.php;
client_max_body_size 10M;
client_body_buffer_size 10M;
location ~* \.php$ {
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
fastcgi_pass your.upstream;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
}
location / {
try_files $uri $uri/ /index.php?$query_string;
}
##
# `gzip` Settings
#
#
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 9;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_min_length 0;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/vnd.ms-fontobject application/x-font-ttf font/opentype image/svg+xml image/x-icon;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment