Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
This is where iptables and a little cron job can be useful.
If you’re regularly being hit by the same IP addresses, to block them out make a rule using iptables. With spam, it’s best to simply drop the traffic so try :
iptables -I INPUT -s xx.xx.xx.xx -j DROP
This will block IP address xx.xx.xx.xx accessing your droplet. You can also use CIDR format to block a range of IP Addresses if necessary.
This is not, however, persistent across a reboot so I’d recommend making a little script and run it at boot time as a cron job.
Assuming you’re logged in as root (if not then su as required)
nano ~/load_iptables.sh
/sbin/iptables -I INPUT -s xx.xx.xx.xx -j DROP
/sbin/iptables -I INPUT -s yy.yy.yy.yy -j DROP
chmod 700 ~/load_iptables.sh
/root/load_iptables.sh
crontab -e
Then add the following to the crontab that opens :
@reboot /root/load_iptables.sh
This will then load and run your script as root each time you restart your server. To add new addresses to block, just add a new line to your load_iptables.sh script.
This is a basic way of dealing with spam. If you are comfortable with linux it’s definitely worth looking at something like fail2ban which is a much nicer automated way of snipping spam attacks in the bud :)
I hope that helps!
Regards, Mike