Firewall Script to Prevent Some DDOS Attacks on Dedicated Servers

I am currently maintaining a dedicated server that uses NGINX as the webserver. One thing that I forgot a month ago was installing a firewall for preventing some denial of service attacks. I assumed that having it be served by Cloudflare will be just fine but it will be more secure if I install a software firewall for the server. So I decided to look for scripts on the web that will make my server acquire a slight security against possible attacks.

I manage to pull some codes from the web and compile it into a single script. You can get the said script from the following:

https://github.com/bleuken/MyFireWall/blob/master/myfirewall.sh

The script blocks certain attacks and blocks unnecessary port. It allows connection from port 80, 443, FTP, SSH and block other services that is not used by the site. It also allow connection from the IP addresses of CLOUDFLARE for smooth connection between my site and the said CDN service.

If you want to add more on the script or want to suggest or comment about it, please feel free to indicate your comment below.

You can skip to the end and leave a response. Pinging is currently not allowed.