Showing posts with label Blog. Show all posts
Showing posts with label Blog. Show all posts

Tuesday, December 8, 2015

Block WordPress XML-RPC Requests Using Apache .htaccess

I recently noticed an increase in unauthorized attempts to access the /xmlrpc.php endpoint of the company WordPress blog. Although the attempts seem to have been unsuccessful, we did decide to limit access to the endpoint to requests originating from the company networks and VPN nodes. The following are some steps you can take if you are facing a similar situation.

Edit the blog .htaccess file:

vi /var/www/html/style-blog/style-blog/.htaccess

Add or update the following:

# Block WordPress xmlrpc.php requests
<Files xmlrpc.php>
order deny,allow
deny from all
allow from 50.111.111.111
allow from 127.0.0.1
</Files>

This blocks access to xmlrpc.php from all hosts except localhost and 50.111.111.111 (the fictitious IP address for the San Francisco Office).

To grant access to a host, simply white-list the host's IP address using the `allow from` directive. The Apache daemon may have to be restarted for the changes to take effect:

sudo /etc/init.d/httpd restart

To test whether it works access http://blog.mycompany.com/xmlrpc.php . The following cURL command can be used to check XML-RPC access is:

curl http://blog.mycompany.com/xmlrpc.php

You should see the following message accessed from a machine whose public IP address is white-listed:

"XML-RPC server accepts POST requests only."

You should see the following output when accessed from a machine whose public IP address is NOT white-listed:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>403 Forbidden</title>
</head><body>
<h1>Forbidden</h1>
<p>You don't have permission to access /xmlrpc.php
on this server.</p>
<hr>
<address>Apache/2.2.31 (Amazon) Server at blog.weddingtonway.com Port 80</address>
</body></html>

Tuesday, December 7, 2010

Turning Over a New Leaf

It has a been few years since I started this blog. I had chosen one of the stock templates offered by Blogspot, and never felt the need to put too much effort into customizing it. Even when Blogspot/Blogger released the new templates, which I have to admit are much nicer than the ones before, yet that alone did not justify switching templates.

This changed today when I realized that the new templates could have a maximum width of 1000px while the old templates had a fixed width. This is something I had desperately needed. The usable area for a text of a blog post was around 460px. The source code snippets and console output dumps which I include in my posts as pre-formatted text often wrap around or need to be scrolled due to the limited width of the post area.

With the new template the usable area for the blog post text is approximately 670px. It doesn't seem like much of an improvement, but it makes a huge difference!

The new design took effect at 11:47pm PST today. It is a slightly modified version of one of the new stock designs. I am not yet done tweaking the new blog design, but I feel that this is a good starting point... for now.

Here is a screenshot of this post with the previous blog template I used, included here more for the sake of nostalgia than anything else.