An ICMP redirect tells a host to send traffic for some address through a different gateway. On a network you don’t fully trust, that is a neat way to reroute traffic, and a server with a fixed route has no use for it.
Check the current values first:
sysctl -a 2>/dev/null | grep -E 'accept_redirects|send_redirects'
Then switch them off in a file under /etc/sysctl.d/:
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
net.ipv6.conf.all.accept_redirects = 0
net.ipv6.conf.default.accept_redirects = 0
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects = 0
Load it with sudo sysctl --system. The kernel docs explain why the example sets both all and default: on a host that does not forward packets, redirects are accepted when either the all value or the interface value is on. default covers interfaces created later, such as a VPN tunnel or a Docker bridge. Interfaces that already exist keep their own value until you set it or reboot.
The send_redirects lines matter only if the box routes traffic. I’d leave them alone on a router where you actually want redirects sent. On a normal single server you lose nothing, since it has one gateway and should stick to it.
Further reading: Linux kernel documentation: IP sysctl