In short
A DDoS attack is an attempt to knock out a server's bandwidth, connection capacity or application with a flood of traffic from a botnet. Volumetric and protocol attacks have to be filtered by network-level infrastructure protection; against application-layer attacks that look like legitimate traffic, you need to apply measures on your own server such as Nginx rate limiting, short timeouts, caching, closed ports and Fail2ban.
In this guide
- DoS vs. DDoS: what's the difference?
- Who gets targeted by DDoS attacks?
- Types of DDoS attacks
- What infrastructure protection does and doesn't cover
- Application-side DDoS protection: 7 practical measures
- How to tell if you're under attack
- What to do during an attack
- Next step: Start with protected infrastructure
A DDoS (Distributed Denial of Service) attack is an attempt to make a server's bandwidth, connection table or application unresponsive with traffic sent at the same time from thousands of compromised devices. Effective DDoS protection has two layers: infrastructure protection that filters large network attacks before they reach the server, and application-side measures that throttle traffic that looks legitimate but sends too many requests. This article covers the attack types, which layer handles what, and what you need to do yourself.
DoS vs. DDoS: what's the difference?
A DoS attack comes from a single source and can be stopped easily by blocking that IP address. In a DDoS attack, traffic comes through a botnet, usually made up of malware-infected computers, IoT devices and rented servers. With so many source IPs, blocking them one by one doesn't work; you need to filter based on traffic patterns.
Who gets targeted by DDoS attacks?
DDoS isn't just a big-company problem. Now that botnets are easy to rent, small online stores, game servers, forums and business sites in highly competitive industries are frequent targets too. The goal is usually to cost you sales during a promotion, demand a ransom or punish a community. That's why protection should be planned when you set up the server, not after an attack starts.
Types of DDoS attacks
Attacks fall into three main groups based on the layer they target. Knowing which type you're facing is the first step to choosing the right defense.
1. Volumetric attacks
The goal is to fill the server's or data center's network link with junk traffic. Their size is measured in bits per second (bps).
- UDP flood: Heavy UDP traffic is sent to random ports.
- Reflection/amplification attacks: The attacker spoofs your address as the source IP and sends small queries to open DNS, NTP, memcached and similar services; those services send much larger responses to you.
Because these attacks can exceed your server's port capacity, they can't be solved on the server; the traffic must be filtered at the network level before it reaches the server.
2. Protocol attacks
These exhaust the resources network devices and the operating system use to track connection state. They're measured in packets per second (pps).
- SYN flood: TCP handshakes are started but never completed, filling the server's half-open connection queue.
- ACK/RST floods and fragmented packet attacks: They strain the capacity of firewalls and connection tracking tables (conntrack).
3. Application-layer (Layer 7) attacks
These hit the most expensive parts of your application with HTTP requests that look like a real visitor. They're measured in requests per second (rps) and are the hardest type to detect.
- HTTP flood: Heavy requests to database-intensive URLs such as search pages, add-to-cart and login forms.
- Slowloris and slow-body attacks: Connections are opened and data is sent very slowly to use up the web server's worker capacity.
- XML-RPC and API abuse: Endpoints that do a lot of work per request are targeted.
What infrastructure protection does and doesn't cover
| Attack type | Infrastructure (network) protection | What you need to do |
|---|---|---|
| Volumetric (UDP flood, amplification) | The main line of defense; traffic must be filtered before it reaches the server | Shut down unneeded UDP services and keep your own server from being used as an amplifier |
| Protocol (SYN flood, etc.) | Handles most of it | SYN cookies, firewall rules, closed ports |
| Application layer (HTTP flood, slowloris) | Partially; it may not fully tell it apart because it resembles legitimate traffic | Rate limiting, caching, timeouts, bot filtering |
In short, infrastructure protection keeps your server's network link from being choked, but only application-side settings will keep a WordPress site up when it's getting hundreds of “normal-looking” requests per second. Sunucu Atlas VDS plans come with layered DDoS protection, which takes on the load at the network level. The measures below finish the job on your side.
Application-side DDoS protection: 7 practical measures
1. Limit requests and connections with Nginx
Cap how many requests a single IP address can send per second and how many connections it can open at once. In the http block:
limit_req_zone $binary_remote_addr zone=genel:10m rate=10r/s;
limit_req_zone $binary_remote_addr zone=giris:10m rate=1r/s;
limit_conn_zone $binary_remote_addr zone=baglanti:10m;
limit_req_status 429;
In your site's server block:
location / {
limit_req zone=genel burst=20 nodelay;
limit_conn baglanti 20;
try_files $uri $uri/ /index.php?$args;
}
location = /wp-login.php {
limit_req zone=giris burst=3 nodelay;
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php-fpm.sock;
}
These values are starting points; tune them while watching your logs so you don't block legitimate visitors. Adjust the PHP-FPM socket path to match your setup. All parameters are explained in the nginx.org limit_req documentation.
2. Short timeouts against Slowloris
client_header_timeout 10s;
client_body_timeout 10s;
keepalive_timeout 15s;
send_timeout 10s;
Thanks to its event-driven architecture, Nginx is more resistant to slowloris than Apache's classic worker model; even so, short timeouts stop slow connections from holding on to resources.
3. Kernel-level SYN flood settings
Add these to /etc/sysctl.d/99-ddos.conf and apply them with sudo sysctl --system:
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_max_syn_backlog = 4096
net.ipv4.tcp_synack_retries = 2
net.ipv4.conf.all.rp_filter = 1
SYN cookies let the server keep accepting new connections even when the half-open connection queue is full.
4. Shrink your attack surface
Services such as databases (3306), Redis (6379) and Memcached (11211) should never be exposed to the internet. Configure them to listen only on 127.0.0.1, and open only the ports you need in your firewall. For setup steps, see the UFW firewall guide.
5. Use caching
A page served from cache never touches PHP or the database. Nginx FastCGI cache or a page caching plugin multiplies how much load your server can withstand during an HTTP flood.
6. Ban repeat offenders with Fail2ban
Block IPs for a set time if they get 429 responses in your Nginx logs or keep hitting your login page. Full setup is in our Fail2ban guide.
7. Hide your origin IP
If you put a reverse proxy or CDN in front of your site, be careful not to expose your server's real IP address in DNS history, email headers or subdomains. Restrict web traffic that hits the IP directly so that only the proxy's IP ranges are allowed.
How to tell if you're under attack
A sudden slowdown doesn't always mean an attack; look at the data first:
# Summary of connection states
ss -s
# Number of half-open (SYN_RECV) connections
ss -tan state syn-recv | wc -l
# Most frequent IP addresses in recent requests
sudo tail -n 5000 /var/log/nginx/access.log | awk '{print $1}' | sort | uniq -c | sort -rn | head -20
# Most requested URLs
sudo tail -n 5000 /var/log/nginx/access.log | awk '{print $7}' | sort | uniq -c | sort -rn | head
A large number of SYN_RECV connections points to a protocol attack, while many IPs sending thousands of requests to the same URL point to an application-layer attack. To rule out resource problems such as CPU or disk exhaustion, also follow the steps in the server bottleneck diagnosis guide.
What to do during an attack
- Stay calm and collect evidence: Record when the attack started, the targeted URLs and sample log entries.
- Identify the targeted endpoint: If the attack focuses on a single page, apply a rate limit or temporary access restriction specific to that URL.
- Temporarily tighten rate limits and extend cache lifetimes for heavy pages.
- Open a support ticket: Share the attack times and the targeted IP with your provider so they can review network-level traffic and decide whether extra measures are needed.
- Don't strike back at the attacker: It's illegal, and it usually hits spoofed source addresses anyway.
Next step: Start with protected infrastructure
Since volumetric attacks can't be stopped on the server, choosing infrastructure with network-level protection is the first and most important step. Ryzen Premium VDS plans with layered DDoS protection run in our Istanbul data center with an AMD Ryzen 9 5900X CPU, NVMe storage and a 1G port; high single-core performance helps PHP and Nginx handle more requests during an HTTP flood. If you want more vCPUs and a wider range of plans, Intel Xeon-based Premium VDS plans come with the same layered DDoS protection. For a mid-sized website or API, SA-R9-4 with 8 GB of RAM is a balanced starting point that comfortably runs rate limiting and caching layers.
Frequently asked questions
Is a DDoS-protected server completely safe?
No. Infrastructure protection filters most volumetric and protocol attacks before they reach the server, but against application-layer attacks that look like real visitors, you need to add measures such as rate limiting and caching yourself.
Can a DDoS attack steal my data?
The goal of a DDoS attack is to make a service unavailable, not to steal data. However, it's sometimes used as a distraction alongside another attack, so keep an eye on your login and error logs during an attack.
How can I tell if I'm under attack?
Check connection states with ss -s, the SYN_RECV count with ss, and repeated IPs and URLs in your access logs. Many half-open connections point to a protocol attack, while thousands of requests to the same page point to an application-layer attack.
Does Fail2ban stop DDoS attacks?
Fail2ban is effective at blocking repeated abuse from a small number of IPs. On its own, it can't stop a volumetric attack from thousands of different IPs; use it together with network-level protection and rate limiting.
Will Nginx limit_req block real visitors?
It can if you set the values too low. Allow short spikes with the burst parameter, and watch 429 responses in your logs to tune the limits to your site's real traffic.