Skip to content

Instantly share code, notes, and snippets.

@HostOnNet
Last active January 28, 2018 17:16
Show Gist options
  • Save HostOnNet/09d06cccad5ba34238be7804659cd8f1 to your computer and use it in GitHub Desktop.
Save HostOnNet/09d06cccad5ba34238be7804659cd8f1 to your computer and use it in GitHub Desktop.
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.php;
client_max_body_size 100M;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
proxy_read_timeout 180;
fastcgi_intercept_errors on;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
location ~* \.(txt|xml|js)$ {
expires max;
log_not_found off;
access_log off;
}
location ~* \.(css)$ {
expires max;
log_not_found off;
access_log off;
}
location ~* \.(flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav|mp4|m4v|ogg|webm|aac|eot|ttf|otf|woff|svg)$ {
expires max;
log_not_found off;
access_log off;
}
location ~* \.(jpg|jpeg|png|gif|swf|webp)$ {
expires max;
log_not_found off;
access_log off;
}
# Compression
# Enable Gzip compressed.
gzip on;
# Enable compression both for HTTP/1.0 and HTTP/1.1.
gzip_http_version 1.1;
# Compression level (1-9).
# 5 is a perfect compromise between size and cpu usage, offering about
# 75% reduction for most ascii files (almost identical to level 9).
gzip_comp_level 5;
# Don't compress anything that's already small and unlikely to shrink much
# if at all (the default is 20 bytes, which is bad as that usually leads to
# larger files after gzipping).
gzip_min_length 256;
# Compress data even for clients that are connecting to us via proxies,
# identified by the "Via" header (required for CloudFront).
gzip_proxied any;
# Tell proxies to cache both the gzipped and regular version of a resource
# whenever the client's Accept-Encoding capabilities header varies;
# Avoids the issue where a non-gzip capable client (which is extremely rare
# today) would display gibberish if their proxy gave them the gzipped version.
gzip_vary on;
# Compress all output labeled with one of the following MIME-types.
gzip_types
application/atom+xml
application/javascript
application/json
application/rss+xml
application/vnd.ms-fontobject
application/x-font-ttf
application/x-web-app-manifest+json
application/xhtml+xml
application/xml
font/opentype
image/svg+xml
image/x-icon
text/css
text/plain
text/x-component;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment