I need to run Apache and Maven on my server, and because of cross-domain security restrictions they must both be running on port 80. Originally I achieved this using HAProxy, but this got in the way of the other websites I host on my VPS. I do have four IPs, however, and it would be very nice to have Apache running port 80 on one IP and Maven running port 80 on another. Then I could easily route a few subdomains to Maven using a CNAME record. Is this possible to do?
Absolutely, you can bind two services to the same port on different IPs.
Just set up Apache and Maven to bind to a specific IP address.
Yes you can. Just bind Apache to one IP, and Maven to another IP
I am going to assume that it is the cross-domain policies of Javascript you are trying to overcome. It is relatively easy to do communication cross subdomain in Javascript, however not by default.
All you would need to do is set up, for example:
If you try to do a call to app.example.com from www.example.com, the clients javascript security will prevent it from doing so. However, you can reduce the restriction from only the subdomain, to the domain itself with the following javascript: