I have two servers under the same domain name:
- Apache webserver listening to port 80
- Node.js server listening to port 8080
What do I need to do in order to run each server on a different ec2 instance? Can I use the AWS load balancer for this?
If you want to keep them under the same domain name, then you'll have to have one server be the "switchboard" and redirect all traffic bound for the server that you moved to whichever instance it's on. The easiest way would be to use iptables (or the firewall of choice on the OS of your choosing) to rewrite all traffic bound to the port of the moved server. If you have a firewall of some kind in front of your instances, then split the traffic up there.
Perhaps the better choice would be to simply use a subdomain DNS entry to send traffic to the new server? webserver.com goes to the Apache server and sub.webserver.com goes to the node.js server?