How I Hardened My Websites and Cut My Hosting Costs
Why I started
Lately it feels like every other week brings news of another breach, often at companies big enough that you would expect them to have it all figured out. Reading those stories, I asked myself a simple question: how well protected are my own websites, and the sites I build for my clients?
So I spent some time reviewing my website security from the ground up. I ended up with sites that are better protected, a server that works less, and, as a nice surprise, lower yearly costs.
The problem: bots knocking all day
If you have ever looked at your server logs, you know the picture. Most of the traffic that ends in a 404 error is not people. It is automated bots trying hundreds of addresses in the hope of finding a weak spot:
- old or forgotten
.phpfiles -
.envfiles, which on a badly configured server can contain passwords and API keys -
.gitfolders, which can expose a site’s source code - standard WordPress login and XML-RPC pages, used to guess passwords
My sites were not vulnerable to these, but every such request still reached the server and used its resources. For a while I blocked the worst offenders by hand. That works, but it never ends: new bots show up every day.
Step 1: stopping bots before they reach the server
I moved my domains’ DNS to Cloudflare and put my websites behind its network. Now every visitor, human or bot, passes through Cloudflare first, and only then reaches my server.
That gives me a filter at the front door. I set up rules that block the typical bot requests (the .env, .git and unwanted .php paths) right at the edge. Those requests never touch my server at all, so there is nothing for it to process and nothing to log.
This works alongside the protection inside the sites themselves, not instead of it. The admin areas still have their own safeguards. The difference is that most of the noise is now stopped one step earlier.
The move itself was smooth: I copied the existing DNS records first and switched over without any downtime for the sites. Later I also transferred the domain registration itself to Cloudflare, which renews domains at cost.
Step 2: my own business email
While I was at it, I looked at email. I had been paying for a hosted mailbox on my domain, and it worked well, but I realized I already had everything needed to run it myself: a server I manage and the domain.
So I set up my own mail server and moved all my mailboxes and old messages over. Email security is mostly about three DNS records, and I made sure all of them are in place:
- SPF tells other mail servers which servers are allowed to send email for my domain.
- DKIM adds a digital signature to every message, so receivers can check it was not forged or changed.
- DMARC tells receivers what to do with messages that fail those checks.
The result scores 10 out of 10 on mail-tester.com, and Gmail confirms that SPF, DKIM and DMARC all pass. One honest note: a brand-new mail server has no reputation yet, so the first messages can land in spam. That settles down with normal, regular correspondence.
The results
The biggest win for my website security is calm. Bot requests to .env, .git and similar paths are now blocked before they reach my server, so the 404 reports are much cleaner, and I no longer block bots by hand.
The second win I did not plan for: I now pay over $100 a year less.
| Yearly cost | Before | After |
|---|---|---|
| Domain | $21.18 | $12.20 |
| Business email | ~$110 (€96) | $0 (runs on my existing server) |
| Total | ~$131 | ~$12 |
The email server runs on the same server that already hosts my sites, so it adds no new bill. The trade-off is that I now look after it myself, including regular backups.
What this means for my clients
I tested all of this on my own projects first, and now I am bringing the same approach to my clients’ websites. In practice, that means:
- bots filtered out before they reach your site
- less load on your server, which helps keep the site fast
- correctly configured domain email, so your messages are trusted and less likely to end up in spam
- no extra monthly fees where they are not needed
None of this replaces good habits like updates, strong passwords and backups. It adds one more layer in front of them.
If you would like to know how well your website is protected, or you want to set up something similar, get in touch. I am happy to take a look.