It can be done via the firewall without any changes to the web server.
iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports <new port here>
Try the rule above. Don't forget to change the <new port here> part to the port that you want to redirect to.
An alternative:
iptables -t nat -I PREROUTING --src 0/0 --dst <your server ip> -p tcp --dport 80 -j REDIRECT --to-ports <new port here>
Here again make sure you adjust <new port here> and also <your server ip>.
If the server is OpenVZ and doesn't have the NAT iptables modules loaded on the hostnode the commands might fail. In that case you might have to build a vHost on port 80 that redirects to the other port. For that take a look at this:
https://stackoverflow.com/a/13089668
My references for the iptable rules:
-
https://www.cyberciti.biz/faq/linux-port...-iptables/
-
https://wiki.debian.org/Firewalls-local-...edirection
P.S.: "throw"? You mean "to".
Throw means absolutely something different.