I have a Ubuntu server (18.04) which hosts some websites on Apache2, and also has a node app running. I want the node app to use SSL, but as it's not running as root it doesn't have permission to listen to ports below 1024.
So I set up an iptables rule like below, and listen on port 8443:
iptables -t nat -A PREROUTING -i eth0 -p tcp -m tcp --dport 443 -j REDIRECT --to-ports 8443
This works for node, but now the websites all break due to a certificate mismatch (Error code: SSL_ERROR_BAD_CERT_DOMAIN
in Firefox). I presume this is due to HTTPS web requests also being forwarded to that same port.
Is there a way to detect and forward only the node requests, leaving Apache alone? Or some other solution.