1

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?

1
  • This question belongs on ServerFault (there is a link at the bottom of this page)
    – Unkwntech
    Jul 10, 2011 at 21:52

2 Answers 2

4

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.

2
  • How does this bypass cross-domain-policies?
    – KingCrunch
    Jul 10, 2011 at 21:53
  • 1
    @KingCrunch - I'm guessing it's got something to do with the ability to map a subdomain to the 2nd IP address, and then depending on the application, set the permissions to permit *.example.com. Anyway that cross domain policy thing is just a bit of a red herring and outside the scope of the question. Jul 11, 2011 at 3:33
2

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:

  • www.example.com - Apache's IP
  • app.example.com - Maven's IP

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:

document.domain = "example.com";

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .