3

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?

Jason
  • 3,247
  • 9
  • 27
  • 28

2 Answers2

3

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.

Shane Madden
  • 114,520
  • 13
  • 181
  • 251
  • I just realized this and came back to post this as a solution. – Jason Oct 26 '11 at 04:38
  • Was about to say the same... in addition, you may find http://confluence.atlassian.com/display/DOC/Using+Apache+with+virtual+hosts+and+mod_proxy 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 04:39
1

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.

Eli
  • 372
  • 2
  • 8
  • 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 04:25
  • Just for kicks have you tried specifying the listening port in the virtual host just to see if it makes a difference? --or whatever port you have Servername jira.domain-two.com ProxyPreserveHost On ProxyPass / http://localhost:8080/ ProxyPassReverse / http://localhost:8080/ – Eli Oct 26 '11 at 04: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 04: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 04:30
  • Which Apache and mod_proxy versions do you have and is this on Linux/Mac/Windows/etc..? – Eli Oct 26 '11 at 04:32
  • Also, another thing that comes to mind is why the localhost? Why not.. Servername jira.submitpatientforms.com ProxyPreserveHost On ProxyPass / http://jira.submitpatientforms.com:8081/ ProxyPassReverse / http://jira.submitpatientforms.com:8081/ – Eli Oct 26 '11 at 04:38