I am trying to setup httpd.conf properly but regardless of the sub-domain/domain combo below, they all resolve to the same internal URL.

<Proxy *>
  Order Allow,Deny
  Allow from all
</Proxy>

ProxyRequests       Off


<VirtualHost *:80>
    Servername      jira.firstfactoryinc.com
    ProxyPreserveHost   On
    ProxyPass       /   http://localhost:8082/
    ProxyPassReverse    /   http://localhost:8082/
</VirtualHost>

<VirtualHost *:80>
    Servername      jira.submitpatientforms.com
    ProxyPreserveHost   On
    ProxyPass       /   http://localhost:8081/
    ProxyPassReverse    /   http://localhost:8081/
</VirtualHost>

<VirtualHost *:80>
    Servername      mddev-jira.firstfactoryinc.com
    ProxyPreserveHost   On
    ProxyPass       /   http://localhost:8080/
    ProxyPassReverse    /   http://localhost:8080/
</VirtualHost>

What am I doing wrong?

link|improve this question

74% accept rate
feedback

2 Answers

up vote 2 down vote accepted

You'll need a NameVirtualHost directive that matches your <VirtualHost> definitions, or else the first <VirtualHost> block to load will be used for all requests on that port (this matches with what you're seeing, correct?).

In the case of the config above:

NameVirtualHost *:80

Outside of a VirtualHost block. Alongside your Listen directive is a good place for it.

link|improve this answer
I just realized this and came back to post this as a solution. – Jason Oct 26 '11 at 4:38
Was about to say the same... in addition, you may find confluence.atlassian.com/display/DOC/… to be a useful example. I essentially emulated that when I was tasked with a similar setup a few years back – sandroid Oct 26 '11 at 4:39
feedback

You may have to add something like this within each VirtualHost, I did:

<Proxy *>
  Order Allow,Deny
  Allow from all
</Proxy>

Obviously that can be modified to suit your security needs.

You may also want to add:

ProxyRequests Off

It is supposed to be the default, but depending on your Apache version and mod_proxy version something could be acting up.

link|improve this answer
Thanks for the advice, but it didn't make a difference. They are all still going to the first one. – Jason Oct 26 '11 at 4:25
Just for kicks have you tried specifying the listening port in the virtual host just to see if it makes a difference? <VirtualHost *:80> --or whatever port you have Servername jira.domain-two.com ProxyPreserveHost On ProxyPass / localhost:8080 ProxyPassReverse / localhost:8080 </VirtualHost> – Eli Oct 26 '11 at 4:28
Also, you may want to add all of your domain names to your /etc/hosts file with the IP address they resolve to - I have seen that problem before as well... - not necessarily the subdomains - but the root domains at least. – Eli Oct 26 '11 at 4:29
I tried your second suggestion and still no luck. Regarding the IPs, they are all the same (one IP) and resolving correctly. – Jason Oct 26 '11 at 4:30
Which Apache and mod_proxy versions do you have and is this on Linux/Mac/Windows/etc..? – Eli Oct 26 '11 at 4:32
show 1 more comment
feedback

Your Answer

 
or
required, but never shown

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