How to Protect Your Website Admin Panel from Hacking
The admin panel is the most valuable part of a website for an attacker: with access to it, they can plant malware, replace your contact details, steal client requests or turn the website into a spam sender. And it isn't hackers attacking it by hand, but bots that try passwords around the clock on thousands of websites in a row.
The good news: most of these attacks are stopped by simple measures. Let's go through them in order — from the ones that take five minutes to the most reliable one: access to the admin panel only from your own network or via VPN.
Why admin panels get attacked
The admin addresses of popular systems are well known: /wp-admin and /wp-login.php in WordPress, /administrator in Joomla, /admin in many others. Bots go to these addresses and try thousands of username and password combinations — from admin/admin to passwords leaked from other websites. If the password is simple or has already leaked somewhere, sooner or later it will match.
You can see how often this happens in the web server log: there are usually hundreds of requests to the login page a day, even for a small website few people know about.
A strong password and username
- A long unique password — 12–16 characters or more, not used anywhere else. The easiest way is to generate it in a password manager.
- Not admin as the username. It's the first thing bots try. Create an administrator with a different name and delete the old one.
- A separate account for everyone who works with the website — with the minimum rights they need. An article editor doesn't need administrator rights.
Two-factor authentication
Even if the password leaks, nobody can sign in without the second factor. Usually it's a one-time code from an app on your phone — for example, Google Authenticator or similar. WordPress and other popular systems have free plugins, and many hosting and server control panels support two-factor authentication themselves.
💡 Tip: when turning on two-factor authentication, keep the backup recovery codes in a safe place. If you lose your phone, without them you may get locked out of your own website.
Limiting login attempts
By default, many systems let you try passwords endlessly. Limit the number of attempts: after a few failures, the address is blocked for a while. For WordPress websites this is done with a plugin, and on your own server with fail2ban, a program that reads logs and blocks overly persistent IP addresses in the firewall.
Access only from your IP addresses
The most reliable way is to make the login page not open for outsiders at all. Then bots have nothing to try. In Apache, this is done with an .htaccess file in the admin folder:
Require ip 203.0.113.10
For WordPress, where the admin panel isn't in a separate folder, you can also close the login page:
<Files "wp-login.php">
Require ip 203.0.113.10
</Files>
In Nginx, with a location block in the website configuration:
location ^~ /admin/ {
allow 203.0.113.10;
deny all;
}
Replace 203.0.113.10 with your IP address — you can find it with any "what is my IP" service. If there are several addresses: in Apache list them separated by spaces in one Require ip line, in Nginx add a separate allow line for each address.
In Nginx, the ^~ modifier makes this rule take priority over the PHP location — otherwise the admin's PHP pages stay open. PHP handling for this folder has to be set up inside the same block, just like in the main website configuration.
⚠️ Important: home and mobile internet IP addresses often change. If yours changes, you'll lock yourself out of the admin panel too. So before setting this up, ask your provider whether your address is static — or use a VPN.
Access via VPN
If you don't have a static IP address or several people work with the website from different places, it's more convenient to set up your own VPN. It's an inexpensive separate server with a static address that you connect to before signing in to the admin panel. The rules above allow only that server's address — so you can sign in from anywhere, but only via the VPN.
WireGuard is a good fit for your own VPN server: it's free, fast and takes a few minutes to set up, and there are apps to connect from a computer and a phone. What matters is that it's your own server: you know its address for sure and decide yourself who gets access.
The server control panel
Besides the website admin panel, the server often has a control panel — for example, FastPanel, ISPmanager or cPanel. It gives access to all websites, databases and files at once, so it needs just as much protection. The panel usually runs on a separate port, and you can open it in the firewall only for your address:
sudo ufw allow from 203.0.113.10 to any port 8888 proto tcp
Here 8888 is the panel's port; it differs between panels. If the port is already open to everyone by a general rule, delete it: ufw applies the first matching rule. The same goes for SSH access to the server: key-based login instead of a password and IP restrictions close the most common way servers get hacked.
⚠️ Important: before closing access, make sure you have a backup way in — for example, the server console in your hosting panel. Otherwise one mistake in the rules can lock you out too.
Extra measures
- HTTPS is a must. Without it, the admin password travels as plain text and can be intercepted on public Wi-Fi.
- A second password on the login page. You can add an extra password to the admin folder at the web server level — bots get filtered out before they even reach your CMS.
- Updates. Many hacks happen not through the password but through vulnerabilities in old versions of the CMS, themes and plugins.
- Unneeded accounts. Delete the accounts of former employees, contractors and test users.
- The login log. Many plugins and panels show who signed in and when. An unfamiliar login is a reason to change passwords right away.
If you suspect the website has already been hacked, see the article "How to Check a Website for Viruses".
Checklist
- the password is long, unique and stored in a password manager;
- the administrator username isn't admin, and every employee has their own account;
- two-factor authentication is on;
- login attempts are limited;
- the admin panel and server panel are open only from your IP addresses or via VPN;
- the website works over HTTPS, and the CMS and plugins are up to date;
- there are no unneeded accounts, and you check the login log from time to time.
Summary
Most admin panel hacks aren't clever attacks but bots trying simple passwords. A strong password, two-factor authentication and login attempt limits stop almost all of them, and access only from your IP addresses or via VPN makes the login page invisible to outsiders.
🔐 Want to close your admin and server panel to outsiders? Message me — I'll set up the protection and, if needed, your own VPN.
Published