ลดความยุ่งยากในการใช้คลาวด์ พูดคุยกับเจ้าหน้าที่

DDoS attacks
Home วิธีป้องกัน DDoS Attack สำหรับ Cloud Private Hosting อย่างมีประสิทธิภาพ

วิธีป้องกัน DDoS Attack สำหรับ Cloud Private Hosting อย่างมีประสิทธิภาพ

การป้องกัน DDoS Attack จำเป็นต้องใช้หลายวิธีร่วมกันเพื่อเพิ่มความปลอดภัยและลดผลกระทบจากการโจมตี

1. ใช้ Web Application Firewall (WAF)

WAF สามารถช่วยกรองและบล็อกทราฟฟิกที่เป็นอันตรายก่อนถึงเซิร์ฟเวอร์

ตัวเลือกที่แนะนำ

  • Cloudflare WAF (ฟรี/เสียเงิน) – กรองทราฟฟิก DDoS ก่อนถึงเซิร์ฟเวอร์
  • ModSecurity – ใช้ร่วมกับ Apache, Nginx, หรือ OpenLiteSpeed
  • BitNinja หรือ Imunify360 – เหมาะสำหรับ Plesk หรือ aaPanel

2. เปิดใช้งาน Rate Limiting บน OpenLiteSpeed

ลดผลกระทบจากทราฟฟิกที่มากผิดปกติโดยจำกัดการร้องขอจาก IP เดียว

วิธีตั้งค่า Rate Limiting บน OpenLiteSpeed:

  1. ไปที่ WebAdmin Console (http://your-server-ip:7080)
  2. ไปที่ Server Configuration > Security
  3. เปิดใช้งาน Per Client Throttling
  4. ตั้งค่า
    – Static Requests/Second: 10
    – Dynamic Requests/Second: 5
    – Connection Limit: 50
  5. Restart OpenLiteSpeed

3. ปิดกั้น IP ที่ DDoS Attack ด้วย Fail2Ban

DDoS Attack fail2ban

ติดตั้ง Fail2Ban บน Ubuntu 22.04

apt install fail2ban

ตั้งค่าป้องกัน DDoS Attack บน OpenLiteSpeed

1. สร้างไฟล์คอนฟิก

nano /etc/fail2ban/jail.local

2. เพิ่มกฎต่อไปนี้

[lsws]
enabled = true
filter = lsws
action = iptables-multiport[name=lsws, port="80,443"]
logpath = /usr/local/lsws/logs/access.log
bantime = 600
maxretry = 20

3. รีสตาร์ท Fail2Ban

systemctl restart fail2ban

4. ใช้ Cloudflare หรือ Reverse Proxy ป้องกัน DDoS

✅ Cloudflare (ฟรี) – ปกป้องเว็บไซต์จาก DDoS ระดับ Layer 3/4/7
✅ Nginx Proxy with Rate Limit – บล็อกบอทที่ส่งคำขอจำนวนมาก

วิธีตั้งค่า Cloudflare

  1. สมัครบัญชีที่ Cloudflare
  2. เพิ่มโดเมนของคุณ
  3. เปิดใช้งาน DDoS Protection Mode และตั้งค่า Under Attack Mode
  4. ใช้ Cloudflare DNS Proxy (Orange Cloud ☁️)

5. ตั้งค่า iptables ป้องกัน SYN Flood

iptables -A INPUT -p tcp --syn -m limit --limit 1/s --limit-burst 3 -j ACCEPT
iptables -A INPUT -p tcp --syn -j DROP
iptables-save > /etc/iptables/rules.v4
อธิบาย: บล็อกแพ็กเก็ต SYN Flood ที่ส่งมามากเกินไป

6. ใช้ LiteSpeed Anti-DDoS Protection

OpenLiteSpeed และ LiteSpeed Enterprise มีฟีเจอร์ป้องกัน DDoS ในตัว

เปิดใช้งาน Dynamic Request Rate Control

  1. ไปที่ WebAdmin Console (http://your-server-ip:7080)
  2. ไปที่ Server Configuration > Security
  3. เปิด Dynamic Request Rate Control
  4. กำหนดค่า
    • Max Dynamic Requests per Second: 5
    • Banned Period (sec): 600

7. จำกัดจำนวนการเชื่อมต่อจาก IP เดียวกัน (Connection Limit)

iptables -A INPUT -p tcp --dport 80 -m connlimit --connlimit-above 50 -j DROP
iptables -A INPUT -p tcp --dport 443 -m connlimit --connlimit-above 50 -j DROP

อธิบาย: จำกัดการเชื่อมต่อจาก IP เดียวที่มากเกินไป

8. เปิดใช้งาน TCP SYN Cookies

echo 1 > /proc/sys/net/ipv4/tcp_syncookies
อธิบาย: ป้องกัน SYN Flood Attack

9. ใช้ Load Balancer หรือ Anycast Network

  • ใช้ Load Balancer เช่น HAProxy หรือ Nginx
  • ใช้ Anycast DNS เช่น Cloudflare หรือ Google Cloud Armor

10. ตรวจสอบและบล็อกทราฟฟิกที่น่าสงสัย

ดูว่า IP ไหนส่งคำขอมากผิดปกติ
netstat -an | grep :80 | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -nr | head -20
บล็อก IP ที่โจมตี
iptables -A INPUT -s 192.168.1.100 -j DROP

สรุปแนวทางป้องกัน DDoS

  • หากคุณใช้ Plesk 👉 ติดตั้ง Imunify360 + Fail2Ban
  • หากคุณใช้ aaPanel 👉 ใช้ Cloudflare + Fail2Ban + iptables
  • หากรับทราฟฟิกสูง 👉 ใช้ Load Balancer + Anycast DNS

สามารถใช้หลายวิธีร่วมกันเพื่อให้การป้องกัน DDoS Attack มีประสิทธิภาพสูง และสำหรับผู้ใช้งาน THAI DATA CLOUD อย่าลืม เปิดใช้งาน Two-Factor Authentication (2FA) บน TDC Cloud Console เพื่อเพิ่มความปลอดภัยให้มากยิ่งขึ้น

ผู้ให้บริการคลาวด์ไทย
เพื่อธุรกิจของคนไทย

"มุ่งมั่น" และ "มั่นคง"
พร้อมรับมือทุกการเติบโต
Trust Cloud
คลาว์ที่ปลอดภัย
คือรากฐานที่มั่นคง
cloud security
Privacy Overview

When you access a website, it has the ability to store or retrieve data on your browser, primarily in the form of cookies. This data could pertain to your preferences, device, or personal information, and is primarily used to optimize the website functionality according to your expectations. While this information typically does not enable direct identification, it does provide a more tailored online experience. As we value your privacy, you are able to selectively decline certain cookie types. Please click on the various category headings to gain more insights and modify our default settings. However, note that preventing certain cookies may impact the level of service and site functionality that we can offer you, please read the full privacy policy