The below guide can be used for redirecting ports. However, please see Apache reverse-proxy SSL to multiple server applications for my preferred solution to both port redirection and SSL.
Redirecting ports (from https to 8443 for example)
We can use iptables to route from https (443) to a local(host) port:
sudo /sbin/iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 443 -j REDIRECT --to-port 8443
You can view all current iptable routes with:
sudo iptables -t nat --line-numbers -L
and delete specific line numbers with (in following example am deleting line 1):
sudo iptables -t nat -D PREROUTING 1
Finally, you should flush the iptables to ensure changes are updated
sudo iptables -F
Making iptables rules persistent
See Make ip-tables (firewall) rules persistent.
Related articles