Skip to content

Instantly share code, notes, and snippets.

@cbunting99
Created October 29, 2023 09:29
Show Gist options
  • Save cbunting99/e86de5f3b9bea92ea8fb06fcf9e2e913 to your computer and use it in GitHub Desktop.
Save cbunting99/e86de5f3b9bea92ea8fb06fcf9e2e913 to your computer and use it in GitHub Desktop.
NGINX - Wordpress security and performance optimization (Old)
##Please create a file folder named wordpress.conf in /etc/nginx/conf.d insert into these codes##
# Common deny or internal locations, to help prevent access to not-public areas
location ~* wp-admin/includes { deny all; }
location ~* wp-includes/theme-compat/ { deny all; }
location ~* wp-includes/js/tinymce/langs/.*\.php { deny all; }
location /wp-content/ { internal; }
location /wp-includes/ { internal; }
location ~ /(\.|wp-config.php|readme.html|license.txt) { deny all; }
# Add trailing slash to */wp-admin requests.
# rewrite /wp-admin$ $scheme://$host$uri/ permanent;
# Prevent any potentially-executable files in the uploads directory from being executed
# by forcing their MIME type to text/plain
location ~* ^/wp-content/uploads/.*.(html|htm|shtml|php|js|swf)$ {
types { }
default_type text/plain;
}
location ~* ^/wp-includes/uploads/.*.(html|htm|shtml|php|js|swf)$ {
types { }
default_type text/plain;
}
location ~* ^/wp-content/cache/page_enhanced.*html$ {
expires max;
charset utf-8;
add_header Vary "Accept-Encoding, Cookie";
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}
location ~* ^/wp-content/cache/page_enhanced.*gzip$ {
expires max;
gzip off;
types {}
charset utf-8;
default_type text/html;
add_header Vary "Accept-Encoding, Cookie";
add_header Content-Encoding gzip;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}
##Have a nice day KBSP##
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment