Skip to content

Instantly share code, notes, and snippets.

@medival
Created August 1, 2021 10:41
Show Gist options
  • Save medival/bd8c77411a47c92ca9a339d07d184a90 to your computer and use it in GitHub Desktop.
Save medival/bd8c77411a47c92ca9a339d07d184a90 to your computer and use it in GitHub Desktop.
server {
listen 80;
listen [::]:80;
server_name www.wp-site.com wp-site.com;
root /usr/share/nginx/wp-site.com/;
index index.php index.html index.htm index.nginx-debian.html;
location / {
try_files $uri $uri/ /index.php;
}
location ~* /wp-sitemap.*\.xml {
try_files $uri $uri/ /index.php$is_args$args;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
client_max_body_size 2M;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
include snippets/fastcgi-php.conf;
}
#enable gzip compression
gzip on;
gzip_vary on;
gzip_min_length 1000;
gzip_comp_level 5;
gzip_types application/json text/css application/x-javascript application/javascript image/svg+xml;
gzip_proxied any;
# A long browser cache lifetime can speed up repeat visits to your page
location ~* \.(jpg|jpeg|gif|png|webp|svg|woff|woff2|ttf|css|js|ico|xml)$ {
access_log off;
log_not_found off;
expires 360d;
}
# disable access to hidden files
location ~ /\.ht {
access_log off;
log_not_found off;
deny all;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment