Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question

migrated from Jul 10 '11 at 21:58

This question came from our site for professional and enthusiast programmers.

This question belongs on ServerFault (there is a link at the bottom of this page) – Unkwntech Jul 10 '11 at 21:52
up vote 4 down vote accepted

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.

share|improve this answer
How does this bypass cross-domain-policies? – KingCrunch Jul 10 '11 at 21:53
@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 * Anyway that cross domain policy thing is just a bit of a red herring and outside the scope of the question. – Mark Henderson Jul 11 '11 at 3:33

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:

  • - Apache's IP
  • - Maven's IP

If you try to do a call to from, 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 = "";
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.