October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
VGSources
Blog

How to Block Malicious Web Scans and Probes on Your Linux Server

A practical, layered guide to stopping malicious probes on a Linux server: block sensitive nginx paths, rate-limit login routes, configure fail2ban against real nginx logs and avoid locking yourself out.
Length11 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The reliable way to reduce malicious scans is layered protection: make nginx reject sensitive paths and obvious probes, rate-limit expensive endpoints before they reach your application, then let fail2ban ban repeat offenders at the firewall. User-agent rules alone are easy to evade, and fail2ban will not work unless it can read nginx’s flat log files and is paired with the firewall backend your Linux distribution actually uses.

What you are defending against

Internet-facing servers are routinely contacted by automated clients looking for exposed configuration files, source-control directories, vulnerable plugins, forgotten administration panels and weak login endpoints. A request for /.env, /.git/config, /wp-login.php or an invented path that produces a 404 is not proof of a compromise, but repeated probes consume bandwidth, fill logs and can reveal an application that has not been patched.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The controls below address different stages of the connection:

  • nginx filtering stops requests at the web-server layer.
  • nginx rate limiting caps requests per client IP before application code runs.
  • fail2ban plus a firewall turns repeated bad behavior into a temporary network-level ban.
  • Host-firewall rules keep unrelated ports closed even if a web application is misconfigured.

These measures reduce exposure and noise; they do not replace operating-system updates, dependency patching, secure authentication or backups.

#1 Best Overall
Sale
Gaoye Blue Light Blocking Glasses
  • BLUE LIGHT BLOCKING GLASSES: Our blue light glasses for women boast UV400 protection, blocking harmful blue rays from computer screens. With these bluelight glasses women, you can enjoy gaming, reading, or watching TV with no worries of eye strain.
  • EYE RELIEF: Our blue light glasses are engineered to reduce blurry vision or strain caused by prolonged screen time. These womens blue light glasses aid in better sleep by preventing blue light from disrupting your natural sleep cycle, helping you fall asleep faster and enjoy a more restful night's sleep, making them the perfect christmas present.
  • COMFORTABLE: Crafted from durable material, our trendy blue light glasses for woman or blue light glasses men ensure long-lasting comfort. The high-transmittance lenses accessories, gamer gifts for men, help keep your eyes relaxed. Perfect stocking stuffers, gifts for gamers men, christmas gifts for men, halloween costumes.
  • LIGHTWEIGHT: These clear blue light glasses feature a lightweight frame, meaning they’ll stay comfy for long-term wear. Perfect as blue blockers glasses for women or mens blue light glasses, these non-prescription fake glasses for men can be worn throughout the day. The blue light blocking glasses women feature polycarbonate HD lenses, which are anti-reflective and restore true color.
  • WORRY-FREE PURCHASE: If you experience any issues, our support team is ready to assist you quickly. These are the perfect costume glasses for cosplay dressing up.

First, close unnecessary network ports

Filtering HTTP traffic cannot protect a database, game-management panel or development service that is listening on the public interface. Use your distribution’s host firewall to expose only the ports you intentionally operate. The following UFW sequence is a starting point on a server where SSH, HTTP and HTTPS are required:

sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow OpenSSH
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enable
sudo ufw status verbose

Run the SSH rule before enabling UFW, and confirm that your SSH service really uses the OpenSSH profile or add its actual port. If you connect through a provider console, keep that recovery channel available before changing firewall policy. Do not open a port merely because a package installed a service; remove or bind unused services to localhost instead.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Block sensitive files and paths in nginx

Return 403 for dotfiles

Dotfiles commonly contain deployment secrets, repository metadata or local configuration. In the server block, reject dotfiles while allowing the ACME challenge directory used by some certificate clients:

location ~ /.(?!well-known) {
    return 403;
}

This regular-expression location also catches nested paths such as /app/.git/config. If your application deliberately serves another dot-prefixed resource, create a narrower exception and test it explicitly rather than weakening the rule globally.

Protect high-value filenames explicitly

A second rule can make the policy obvious and cover common names even when a later configuration changes the general dotfile rule:

location ~* ^/(?:.git|.env|.htaccess|composer.(?:json|lock)|package-lock.json)(?:/|$) {
    return 403;
}

Adjust the list to your deployment. Never place secrets in the document root as a substitute for access control. A 403 response still tells a scanner that the web server understood the path, but it prevents nginx from serving the file. If you prefer to reveal less information, return 404 for paths that should appear nonexistent; use one policy consistently so your logs remain easy to interpret.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Handle known probes that should never reach your application

If your site does not use a path such as /wp-login.php, an exact location can terminate the request cheaply:

Rank #2
Windex Gaming Cleaning Wipes, Pre-Moistened Wipes to Instantly Clean all Gaming Gear and Electronics, Resealable Packaging for a Freshness Lock, 25 count (Pack of 1)
  • WINDEX GAMING WIPES: effortlessly clean all your gaming gear and gaming electronics in one easy step with our new Windex Gaming Wipes
  • AMMONIA FREE: our ammonia-free formula is safe to use on all of your favorite gaming equipment like consoles, headsets, controllers, screens, keyboards, and more
  • PRE-MOISTENED WIPES: each wipe instantly removes dust, dirt, and stubborn smudges and fingerprints leaving a streak-free shine
  • ANTI-STATIC: great for cleaning and wiping down your gaming gear and electronics leaving behind no visible residue
  • COMPACT RESEALABLE PACKAGE: store your pack of Windex Gaming Wipes anywhere in your home for whenever a quick and easy wipedown is needed
location = /wp-login.php {
    return 404;
}

If you do run the endpoint, do not blanket-block it. Put it behind the stricter login rate limit described below, require the application’s normal authentication controls and monitor failed attempts. The same principle applies to administration URLs for control panels and game services: block paths that are definitely absent, but do not guess at paths your users need.

Drop obvious scanner user agents, with realistic expectations

Many basic probes identify themselves with names such as sqlmap, nikto or nmap. nginx can match those strings in the http context and return its non-standard 444 response, which closes the connection without sending a response body:

map $http_user_agent $known_scanner {
    default 0;
    ~*(sqlmap|nikto|nmap) 1;
}

server {
    if ($known_scanner) {
        return 444;
    }

    # your normal listen, server_name and locations follow
}

Place the map outside the server block, normally in the main nginx configuration’s http section. Test the complete configuration before reloading:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo nginx -t
sudo systemctl reload nginx

User-agent matching is a low-effort noise filter, not authentication. A scanner can send an ordinary browser string, omit the header or copy the user agent of a legitimate client. Do not use this rule as the only defense, and do not block broad terms such as “bot” that may match search crawlers or accessibility tools you intend to allow. Review access logs after deployment to catch false positives.

Rate-limit requests before application code runs

Create separate zones for ordinary traffic and logins

nginx’s limit_req module tracks a key, commonly the client IP, in shared memory. Define zones in the http context:

limit_req_zone $binary_remote_addr zone=general_per_ip:10m rate=5r/s;
limit_req_zone $binary_remote_addr zone=login_per_ip:10m rate=1r/s;

The first zone permits an average of five requests per second per IP; the second permits one. The 10 MB allocation stores the counters and is not a bandwidth limit. Select rates from your application’s normal traffic, not from a random example. Shared corporate NAT, mobile networks and some game communities can put many real users behind one address, so an aggressive per-IP limit can affect legitimate players.

Apply the general limit to public locations

server {
    limit_req zone=general_per_ip burst=20 nodelay;
    limit_req_status 429;

    location / {
        try_files $uri $uri/ /index.html;
    }
}

burst allows a short queue of excess requests; nodelay rejects beyond that burst immediately instead of spacing them out. Remove nodelay if smoothing occasional bursts is more important than immediate rejection. A 429 status is useful to clients and monitoring systems; it also gives fail2ban a consistent log event when nginx records a limit violation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
LISEN Cell Phone Stand Phone Holder for Desk, Office Decor Gadgets for Men
  • Ergonomic & Adjustable Design: Fight "text neck" and improve your posture. Designed for comfort, it offers an adjustable height (7.1in-8.5in) (1.4in adjustable range) and angle (5°-85°) Please note: cell phone stand is only 9 inches tall—the length of a standard pencil
  • Without blocking subtitles Perfect for office desk Tiktok Face Time Zoom video—this is the ultimate kitchen desk essential for phones! Perfect viewing experience while reducing neck back strain, A must-have for gamers streamers desk, and anyone who values both style and support!
  • Sleek & Stable Design fits Otterbox Case: Say goodbye to bent cables, tangles, and tip-overs! LISEN’s stylish adjustable desk phone holder features a built-in charging hole and smart cable management, keeping your phone secure and your workspace clutter-free cool gadgets for men
  • ANTI-SLIP DESIGN free hands: The under 10.00 items easy gadgets back and the bottom of this kitchen essentials for women are fully covered by anti-skid silicone, which LISEN stand up desk decor can provide maximum protection device from any scratches and slides
  • Your Perfect Viewing Companion:If your product arrives damaged or breaks within 365 days, reach out to LISEN for a quick and hassle-free solution. Struggling with assembly, like tightening the screw? We’ve got your back! Your experience matters to us. (Product including: phone Holder stand*1, screw*1, hexagon screwdriver*1, specification*1)

Use a stricter rule for authentication

location = /login {
    limit_req zone=login_per_ip burst=5 nodelay;
    limit_req_status 429;
    proxy_pass http://app_backend;
}

location = /wp-login.php {
    limit_req zone=login_per_ip burst=3 nodelay;
    limit_req_status 429;
    try_files $uri =404;
}

Replace /login and the upstream with the routes your application actually uses. Protect password-reset, token-issuance and other expensive authentication endpoints as well. Keep the limit at nginx, but enforce account lockout, multi-factor authentication and password hashing in the application; an IP limit cannot stop a distributed password attack.

If nginx sits behind a reverse proxy, every request may appear to come from the proxy unless the real-client-IP configuration is correct. Configure trusted proxy addresses and the appropriate real-IP module before using an IP-based zone. Never trust an arbitrary client-supplied forwarding header, or an attacker could make each request appear to originate from a different address.

Use fail2ban to ban repeat offenders

How the nginx jails work

fail2ban watches log lines, counts matches during a time window and asks a firewall action to block the offending address for a specified period. Useful nginx-oriented jails include:

  • Scanner or bot-search jail: catches requests matching common probe patterns.
  • Rate-limit jail: watches nginx error-log lines generated when limit_req rejects requests.
  • High-404 or high-403 jail: detects an address generating many nonexistent or forbidden paths in a short period.

Filter filenames and regular expressions vary by fail2ban release and distribution. Inspect the filters installed on your server instead of assuming that a tutorial’s names exist:

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
ls /etc/fail2ban/filter.d/nginx*.conf
sudo fail2ban-client status

Point jails at nginx’s actual log files

nginx normally writes flat files such as /var/log/nginx/access.log and /var/log/nginx/error.log; it does not automatically write these events to the systemd journal. A jail that inherits a systemd backend may therefore see no matches. Set an explicit path and, where needed, use the polling backend:

[nginx-limit-req]
enabled = true
filter = nginx-limit-req
logpath = /var/log/nginx/error.log
backend = polling
maxretry = 10
findtime = 1m
bantime = 1h

The filter name above is an example of the conventional built-in name. Confirm that the corresponding file exists and that its expression matches your nginx error format. For a scanner jail, use the same pattern with the access-log path and a longer ban:

[nginx-botsearch]
enabled = true
filter = nginx-botsearch
logpath = /var/log/nginx/access.log
backend = polling
maxretry = 2
findtime = 10m
bantime = 3d

Short bans suit noisy rate-limit violations; multi-day bans are reasonable for repeated scanner probes when you have verified that legitimate clients are not matching. A long ban is not automatically safer: shared addresses, carrier NAT and compromised hosting ranges can create collateral damage.

Rank #4
Ledagic IC+RGBW USB Powered Led Light Bar with App & Remote Control, 2 Pack
  • Easy Installation: Our gaming lights have been designed to enhance your entertainment experience. Simply position the led light bar next to your TV or game console to create a game room environment with ease. They come with USB power and a 60 inch cord for direct mounting and mobility
  • Audio Syncing & Extensive Mode: The built-in high-sensitivity music sensor allows you to sync the TV led lights to your favorite music. Lights react and move to the beat of music, film and game audio, creating an incredible immersive sound and light experience – and all without the need for an additional hub. You can choose from 64+ patterns, including strobe, illusion, jump, energy, gradient, running, chasing, fluttering mode etc. Each mode can be applied to different scenes
  • 64+ Chasing IC+RGB & W Effect: The independent control design of IC+RGB and white all-in-one multifunctional rgbw led bar lights monitor backlight allows you to easily switch the led lights for desk between IC+RGB and white to enjoy a variety of lighting effects, you can choose white lighting mode with high brightness for better illumination when working, etc. Choose IC+RGB lighting mode when you need to create an entertaining atmosphere for the light show, 16 million colours of Color changing rgb light bar let you dance to the beat and create a dynamic party atmosphere
  • Dynamic and Dimmable Lights: 1%-full brightness free brightness adjustment gives you the flexibility to adjust dimmable led light bar for room decorations or a variety of occasions
  • USB Powered: USB light bars for room can be powered by powernank, usb charger, TV, Monitor, laptop PC mainframe, making behind TV led lighting bar easy to install in any location.TV led lights are powered by the TV usb interface / PC mainframe, can be turned on/off synchronously with TV / PC

Choose the firewall action that your system supports

The traditional action is iptables-multiport. On systems using nftables, an nftables-multiport action may be the correct choice. Do not copy an action name blindly; check the firewall in use and the action files installed under /etc/fail2ban/action.d/. A jail can specify the action explicitly, for example:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
action = iptables-multiport[name=nginx-botsearch, port="http,https", protocol=tcp]

Use the equivalent nftables action when your distribution manages filtering with nftables. After editing /etc/fail2ban/jail.local, validate the configuration and restart the service:

sudo fail2ban-client -t
sudo systemctl restart fail2ban
sudo fail2ban-client status nginx-botsearch

Validate filters against real logs

Before enabling an aggressive jail, run the installed filter against a copy or the current log and inspect the matched lines:

sudo fail2ban-regex /var/log/nginx/access.log /etc/fail2ban/filter.d/nginx-botsearch.conf
sudo fail2ban-regex /var/log/nginx/error.log /etc/fail2ban/filter.d/nginx-limit-req.conf

Published defaults differ, and a custom access-log format can prevent a filter from matching. Test both a known malicious-looking line and a normal request. For a high-404 jail, create a filter whose expression matches your exact nginx access format, then test it with fail2ban-regex before setting a low maxretry. A malformed expression can silently produce no bans; an overbroad expression can ban search engines, monitoring systems or players.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Prevent self-inflicted lockouts

Whitelist administration addresses before testing

Add loopback addresses and your fixed administration address to the jail’s ignoreip list. The following uses a documentation address; replace it with the address or VPN range from which you administer the server:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
[DEFAULT]
ignoreip = 127.0.0.1/8 ::1 198.51.100.10

If your public address changes, a static whitelist can become stale. A private VPN or provider console is safer than repeatedly editing firewall rules over an untrusted connection.

Know how to remove a ban

List active jails and then remove an address from the specific jail:

Best Value
Sale
HUANUO FlowLift™ Dual Monitor Stand, Fully Adjustable Gaming Monitor Desk Mount for 13–32″ Computer Screens, Full Motion VESA 75x75/100x100 with C-Clamp & Grommet Base, Each Arm Holds 4.4 to 19.8 lbs
  • Compatible with Wide Screens - To ensure compatibility with the dual monitor mount, your each monitor must meet three conditions at the same time: First, computer screens size range: 13 to 32 inches. Second, screen weight range: 4.4 to 19.8 lbs. Third, the back of the monitor screen must have VESA mounting holes with a pitch of 75x75mm or 100x100mm.
  • Regarding the compatibility with desks - Your desk must meet three conditions at the same time: First, desk material: Only wooden desks are recommended, plastic or glass desks cannot be used. Second, desk thickness range: 0.59" - 3.54". Third, the bottom of the desk should not have any cross beams or panels, as this will interfere with installation. We recommend carefully checking that your desk and monitors meets all above conditions before purchasing.
  • Dual C-Clamp Hold - Worried your dual monitors might wobble or slip? Our upgraded base uses a larger platform plus a dual C-clamp structure to lock the dual monitor arm firmly to your desk. Each arm safely keeps your screens steady while you type, click and game—no shaking, no sliding, just a clean and secure setup you can trust every day. It also provides Grommet Mounting installation choice, both options ensure stable and secure fixation for your 0.59" - 3.54" desk.
  • Full-Motion Adjustment For Comfortable View - Pull the screen closer when you’re deep in a spreadsheet, push it back to watch videos, or rotate to portrait for coding — moving everything smoothly with just one hand. The monitor stand offers +85°/-50° tilt, ±90° swivel and 360° rotation. Raise your monitor up to 15.75″ to support a healthy sitting posture. Whether you’re working from home, gaming through the night, or switching between video calls and documents, getting the screens to your natural line of sight helps relieve neck, shoulder and back strain so you can stay focused longer with less fatigue.
  • Keep Your Desk Organized: By lifting both screens off the desktop, this dual monitor stand opens up valuable space for your keyboard, notebook, docking station or a simple, clutter-free work area. Built-in cable management guides wires along the arms, keeping cords out of sight and out of the way. Enjoy a tidy, modern workstation that looks as good as it feels to use.
sudo fail2ban-client status
sudo fail2ban-client status nginx-botsearch
sudo fail2ban-client set nginx-botsearch unbanip 203.0.113.24

The last address is from a documentation-only range. Substitute the real address shown in the jail status output. If the ban was inserted directly by a firewall action, inspect the action’s current rules and remove it through the same firewall backend rather than deleting unrelated rules.

Watch the service after deployment

sudo journalctl -u fail2ban -f
sudo tail -f /var/log/nginx/access.log /var/log/nginx/error.log

Look for failed starts, missing log files, permission errors and a growing count of bans. Rotate logs without breaking the jail’s ability to reopen them, and ensure fail2ban restarts automatically after a reboot.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Which control should you deploy first?

Control Where it acts Deployment effort Spoof resistance Main false-positive risk
Dotfile and path rules nginx request handling Low High for exact paths Blocking a resource your application genuinely serves
User-agent rule nginx request handling Low Low; headers are trivial to change Matching a legitimate tool with an unfortunate user-agent string
General rate limit nginx, before application code Low to medium Medium against a single IP; weak against distributed clients Shared NAT or bursty legitimate traffic
Login rate limit nginx, on authentication routes Medium Medium Users behind one address sharing a login budget
fail2ban jail Firewall after log evidence Medium to high Higher than user-agent matching, but IPs can be shared or rotated Bad regex, proxy addresses or an overly short threshold
Host firewall Network perimeter Low to medium High for closed ports Locking out SSH or a required service

For most servers, install the host-firewall baseline and nginx path rules first, then add conservative rate limits. Enable fail2ban only after you have confirmed log paths, filter matches and a recovery route.

Troubleshooting common failures

nginx refuses to reload

Run sudo nginx -t and read the file-and-line error. A map directive inside a server block, a misspelled variable or a duplicate zone name is a common cause. Correct the configuration and test again before reloading.

Requests are limited, but fail2ban never bans

Check that nginx writes “limiting requests” messages to the file named by logpath, that the filter file exists, and that the jail is enabled. Run fail2ban-regex against the real file. If the server uses a custom log directory or containerized nginx, point the jail at the mounted file rather than an empty host path.

Every client appears to be one IP

This usually means a reverse proxy or load balancer is in front of nginx. Correct trusted-proxy and real-client-IP settings first. Otherwise, rate limiting and bans can punish the proxy itself and affect every visitor.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Legitimate visitors receive 403 or 429

Inspect the matching path, user agent and source address. Narrow a regular expression, increase a burst allowance or exempt a verified health-check address. Do not simply disable all protections; change one threshold at a time and observe logs.

A banned address returns after the ban expires

That is expected for rotating scanners. Keep the nginx filters and rate limits in place, choose a ban duration appropriate to the behavior and consider upstream network filtering for sustained distributed abuse. A temporary IP ban cannot remove the underlying vulnerability, so patch the application and dependencies as well.

A deployment checklist

  • Confirm which ports must be public and deny the rest with the host firewall.
  • Back up nginx and fail2ban configuration before editing.
  • Reject dotfiles and known secret filenames, while preserving only deliberate exceptions.
  • Use user-agent blocking only as a noise filter.
  • Define separate general and authentication rate-limit zones.
  • Verify real client IP handling when a proxy or load balancer is present.
  • Whitelist an administration address and confirm an out-of-band recovery path.
  • Set explicit nginx access- and error-log paths in fail2ban jails.
  • Choose iptables or nftables actions to match the distribution’s actual backend.
  • Run nginx -t, fail2ban-client -t and fail2ban-regex before enabling bans.
  • Record the exact unban command and test it safely.
  • Continue patching the operating system, web server, frameworks, plugins and authentication endpoints.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.