Apache Reverse Proxy: only one proxy directive is working. Second one is ignored

39 Views Asked by At

I am using Apache 2.4.58 with Windows server 2019 essentials. I have only 1 server and 1 public IP address with 2 network cards: 192.168.3.100 and 192.168.3.200. I created 2 proxy directives in httpd-ssl.conf

<VirtualHost _default_:443>

<Proxy "http://192.168.3.100:20300/">
  Require expr "(%{HTTP_HOST} == 'domain1.com') || (%{HTTP_HOST} == 'www.domain1.com')"
  ProxyPreserveHost On
  RequestHeader set X-ProxyBase "/"
</Proxy>
  ProxyPass "/" "http://192.168.3.100:20300/"
  ProxyPassReverse "/" "192.168.3.100:20300/"

<Proxy "http://192.168.3.200:20600/">
  Require expr "(%{HTTP_HOST} == 'domain2.com') || (%{HTTP_HOST} == 'www.domain2.com')"
  ProxyPreserveHost On
  RequestHeader set X-ProxyBase "/"
</Proxy>
  ProxyPass "/" "http://192.168.3.200:20600/"
  ProxyPassReverse "/" "192.168.3.200:20600/"

</VirtualHost>

The problem is that only the proxy http://192.168.3.100:20300/ is executed and I can access only domain1.com! If I try to access domain2.com, I am getting the below error message:

"Forbidden You don't have permission to access this resource."

And if I invert the order of the 2 proxies, it does not matter. Domain2.com is accessible only if I comment domain1.com proxy.

What can be the problem?

0

There are 0 best solutions below