Skip to content

Instantly share code, notes, and snippets.

@rszuban
Created September 18, 2018 08:30
Show Gist options
  • Save rszuban/7911965b6c0c19141749792d057da52d to your computer and use it in GitHub Desktop.
Save rszuban/7911965b6c0c19141749792d057da52d to your computer and use it in GitHub Desktop.
Denying access to Wordpress xmlrpc.php via Nginx Server block
server {
listen 80;
server_name your_amazing_site.com www.your_amazing_site.com;
root /var/www/your_amazing_site.com;
index index.php;
access_log /var/log/nginx/your_amazing_site.com.access.log;
error_log /var/log/nginx/your_amazing_site.com.error.log;
location / {
try_files $uri $uri/ /index.php?$args;
}
# Return 403 error for requests to xmlrpc.php
location = /xmlrpc.php {
deny all;
access_log off;
log_not_found off;
}
# pass the PHP scripts to FastCGI server listening on unix sock
location ~ \.php$ {
fastcgi_pass unix:/var/run/php-fpm/php56-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment