
WordPress Security Hardening: A Defence-in-Depth Case Study
WordPress security hardening requires more than a single firewall. This case study demonstrates how I secured an Ubuntu-hosted WordPress website using Wordfence, Fail2ban, DrayTek firewall protection, multi-factor authentication and automatic software updates.
The WordPress Security Challenge
A client hosting a WordPress website on an Ubuntu Linux server wanted to strengthen its protection against unauthorised access, automated login attacks and other internet-based threats.
The website was functioning correctly, but the client recognised that simply placing a server behind a firewall did not provide comprehensive security.
The objective was to establish multiple layers of protection, reduce the website’s exposure to common attacks and introduce automated security responses while maintaining access for legitimate visitors.
The guiding principle
Security should be designed into infrastructure from the outset, rather than implemented only after an incident occurs.
This principle shaped the project, from the network perimeter through to the operating system, Apache web server, WordPress application and administrator account.
Initial Security Assessment
An assessment of the existing infrastructure established the website’s operational requirements, potential attack surface and opportunities for additional protection.
Ubuntu Linux Hosting
The website was hosted on Ubuntu Server 26.04 LTS, providing a Linux-based platform for Apache and WordPress.
Restricted Administration
The website required only one administrator account. Public user registration and visitor comments were unnecessary, reducing the number of exposed application features.
DrayTek Firewall
The hosting server was located behind a DrayTek router and firewall, providing an existing platform for network-level access restrictions.
Public Authentication Endpoints
Although the website did not support public user accounts, its WordPress administration and authentication endpoints remained accessible from the internet.
The WordPress Security Strategy
Rather than relying on a single security product, I implemented a defence-in-depth approach incorporating independent and complementary protection mechanisms.
| Security Layer | Technology | Purpose |
|---|---|---|
| Network perimeter | DrayTek Firewall | Restrict unwanted traffic before it reaches the server. |
| Web server | Apache Access Controls | Reject selected requests from identified networks before WordPress processes them. |
| Operating system | Fail2ban | Automatically restrict IP addresses exhibiting repeated suspicious activity. |
| Application | Wordfence | Provide WordPress-specific firewall protection, login security and threat monitoring. |
| Authentication | Multi-Factor Authentication | Protect the administrator account with an additional verification requirement. |
| Vulnerability management | Automatic Updates | Keep WordPress core, plugins and themes updated with available security fixes. |
Implementation: Building the Security Layers
Each security measure was introduced to address a different risk, ensuring that the website did not depend on a single defensive mechanism.
DrayTek Perimeter Firewall Protection
Configured geographical access restrictions using the DrayTek firewall’s Country Object functionality, informed by publicly available threat intelligence and observed malicious activity.
Additional IP objects and firewall restrictions were subsequently introduced for specific networks identified through investigation, including infrastructure associated with VPN and IP address management services.
This provided an opportunity to reject unwanted traffic at the network perimeter, before requests reached the Ubuntu server.
Automated Intrusion Prevention with Fail2ban
Deployed Fail2ban on Ubuntu to monitor system and application logs and automatically respond to suspicious activity.
A dedicated WordPress jail monitored Apache access logs for repeated POST requests to WordPress authentication endpoints. When five matching requests were recorded within ten minutes, Fail2ban could apply a temporary firewall ban lasting twelve hours.
This detection rule identified repeated login activity rather than independently verifying every authentication failure.
A separate Fail2ban jail also provided protection for SSH administration.
Wordfence Web Application Firewall
Installed and configured Wordfence to provide application-level security specifically designed for WordPress.
The solution included a Web Application Firewall, login attempt monitoring, temporary lockouts, malware scanning and security event logging.
Wordfence provided visibility into attempted usernames, offending IP addresses and repeated authentication activity, supporting subsequent security investigations.
Further information about the security plugin is available from the official Wordfence website.
Administrator Multi-Factor Authentication
Verified that the sole WordPress administrator account was protected using two-factor authentication.
This introduced an additional authentication requirement beyond the account password, reducing the risk of unauthorised access if credentials were exposed or guessed.
Automatic WordPress, Plugin & Theme Updates
Configured automatic updates for WordPress core, installed plugins and themes to help ensure that available security fixes and software improvements were applied promptly.
Keeping these components updated is an essential part of reducing exposure to known vulnerabilities, particularly where outdated plugins or themes could otherwise provide an entry point for attackers.
Automatic updating was incorporated into the ongoing security strategy, alongside monitoring update results and verifying continued website functionality.
Targeted Apache Access Restrictions
Following analysis of repeated login attempts, additional access controls were implemented through Apache to restrict identified unwanted networks from accessing the WordPress login endpoint.
This provided another security layer by rejecting selected requests before the WordPress application was executed, reducing unnecessary application-level processing.
Real-World Attack Investigation
Following implementation, Wordfence detected sustained automated attempts to access the WordPress administration interface.
The activity involved repeated requests to WordPress authentication endpoints, attempts using nonexistent usernames and rapidly changing browser user-agent information.
By correlating Wordfence security records with Apache access logs, I identified concentrations of suspicious activity originating from several IP address networks.
Wordfence Security Events
Reviewed lockout notifications, attempted usernames and source IP addresses to establish the nature and frequency of the suspicious activity.
Apache Request Investigation
Examined HTTP requests, timestamps, response codes and user-agent strings to identify repeated patterns of automated login activity.
Source Network Identification
Grouped suspicious IP addresses by network range and examined registration information to identify concentrations of activity associated with externally hosted infrastructure.
Targeted Access Restrictions
Applied additional restrictions at the Apache and DrayTek firewall layers to reduce unwanted access attempts from the identified sources.
Security monitoring in practice
Following the Apache restrictions, monitoring identified 31 HTTP 403 responses among 36 requests originating from the three initially targeted networks during the observed period.
This was consistent with the new access controls rejecting most of those requests. Subsequent Wordfence alerts also began to decrease after additional perimeter restrictions were applied.
The investigation demonstrated how application security events and server logs can be combined to support evidence-based security decisions.
Ongoing WordPress Security & Maintenance
Cybersecurity is not a one-time installation exercise. Threats evolve, new vulnerabilities are discovered and automated scanning continues regardless of whether an organisation has previously experienced an incident.
The ongoing approach therefore includes monitoring Wordfence security events, reviewing Fail2ban activity, checking firewall restrictions and ensuring WordPress core, plugins and themes remain updated.
Temporary network restrictions should also be periodically reviewed to ensure they remain justified and do not unnecessarily prevent legitimate visitors from accessing the website.
Why automatic updates matter
Even a well-configured firewall cannot compensate for every vulnerability in outdated software. Automatic updates help reduce the period during which known software vulnerabilities remain unpatched.
Combined with monitoring, backups and recovery planning, update management forms an important part of maintaining a secure and reliable WordPress environment.
The Outcome: Security Built into Every Layer
The project established a layered security architecture designed to reduce exposure to common WordPress attacks while maintaining legitimate website access.
- Network-level restrictions implemented using the DrayTek firewall.
- Targeted Apache controls introduced for suspicious login traffic.
- Fail2ban configured to automatically ban repeat offenders.
- Wordfence deployed for application-level threat detection and protection.
- Administrator access secured using multi-factor authentication.
- Automatic updates enabled for WordPress core, plugins and themes.
- Suspicious login activity investigated using Wordfence records and Apache logs.
- Additional network restrictions introduced based on observed attack patterns.
- Website accessibility maintained throughout the investigation and mitigation process.
How Secure Is Your Business Website?
Whether you’re running WordPress, hosting business applications or managing your own server infrastructure, I can help assess your existing security arrangements and implement practical measures to reduce risk and protect your systems.
