Documentation

Wordpress Nginx Config

A
Adam Birds
Published 10 August 20261 min read3 views

Here is the Nginx Config for a Public Wordpress with a locked down Admin section:

upstream examplecombackend {
server unix:/var/run/php-fcgi-examplecom.sock;
}

server {
listen 80;
server_name example.com;
root /var/www/vhosts/example.com/htdocs;
index index.php;

access_log /var/www/vhosts/example.com/access.log;
error_log /var/www/vhosts/example.com/error.log warn;

location / {
try_files $uri $uri/ @handler;
index index.php index.html;
}

#       location /app/                  { deny all; }
#       location /includes/             { deny all; }
#       location /lib/                  { deny all; }
#       location /media/downloadable/   { deny all; }
#       location /pkginfo/              { deny all; }
#       location /report/config.xml/    { deny all; }
#       location /images/               { deny all; }
#       location /var/                  { deny all; }
1.
#       location /download/             { allow 1.1.1.1; deny all; }

location /. {
return 404;
}

location @handler {
rewrite ^/(.*)$ /index.php;
}

#        location ~ \.zip$ {
#                allow 1.1.1.1;
#                deny all;
#        }

location ~ ^/wp-(admin|login).php {
location ~ \.php$ {
fastcgi_intercept_errors on;
fastcgi_pass examplecombackend;
fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
include        fastcgi_params;
}
}
location ~ \.php$ {
fastcgi_intercept_errors on;
fastcgi_pass examplecombackend;
fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
include        fastcgi_params;
}

#        location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
#                expires max;
#                log_not_found off;
#        }

}
Last updated: 10 August 2026v1