Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 58 additions & 7 deletions .docker/wordpress-nginx/default.conf
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
map $uri $is_php_entry_point {
default 0;
~^/(index|wp-login|wp-cron|wp-comments-post|wp-signup|wp-activate|wp-trackback|wp-links-opml)\.php$ 1;
~^/wp-admin/((network|user)/)?[^/]+\.php$ 1;
/wp-includes/js/tinymce/wp-tinymce.php 1;
}

server {
listen 80;
server_name nginx localhost;
index index.php index.html index.htm;
root /var/www/html;
client_max_body_size 0;
client_max_body_size 10m;
server_tokens off;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-XSS-Protection "1; mode=block" always;
Expand All @@ -22,11 +29,59 @@ server {
try_files $uri $uri/ /index.php$is_args$args;
}

location ~* ^/wp-content/.*/vendor(-bin)?/.*\.php$ {
location = /xmlrpc.php {
deny all;
}

location ~ /\.(?!well-known/) {
deny all;
}

location ~ ~$ {
deny all;
}

location ~* \.(sql|sqlite|bak|old|orig|save|swp|swo|log|sh|dist|lock|tar|tgz|gz|bz2|xz|7z|rar|wpress|env|ini|neon|ya?ml|md)$ {
deny all;
}

location ~* /(composer\.(json|lock)|package(-lock)?\.json|phpunit[^/]*\.xml(\.dist)?)$ {
deny all;
}

location ~* ^/wp-content/(debug\.log|updraft|ai1wm-backups|aiowps_backups|backups?[^/]*|upgrade|upgrade-temp-backup|cache|logs)(/|$) {
deny all;
}

location ~* ^/wp-content/uploads/(wc-logs|woocommerce_uploads|debug-log-manager)/ {
deny all;
}

location ~ \.php$ {
location ~* "^/wp-content/uploads/[0-9]{4}/[0-9]{2}/[^/]+\.zip$" {
try_files $uri =404;
}

location ~* \.zip$ {
deny all;
}

location ~* ^/wp-content/(plugins|themes)/[^/]+/(tests|stubs|node_modules|vendor-bin)/ {
deny all;
}

location ~* ^/wp-content/(.*/)?vendor/.+\.(css|js|map|gif|ico|jpe?g|png|svg|webp|eot|ttf|woff2?)$ {
expires max;
log_not_found off;
}

location ~* ^/wp-content/(.*/)?vendor(-bin)?/ {
deny all;
}

location ~* \.(php[0-9]?|phtml|phar|pht)(/|$) {
if ($is_php_entry_point = 0) {
return 404;
}
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass wordpress:9000;
Expand All @@ -36,10 +91,6 @@ server {
fastcgi_param PATH_INFO $fastcgi_path_info;
}

location ~ /\.(ht|git) {
deny all;
}

location = /favicon.ico {
log_not_found off;
access_log off;
Expand Down
Loading