How to properly use VirtualHost and mod_proxy together for different incoming domain names and internal ports?

Solution 1:

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.

Solution 2:

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.