1

I have an instance of apache web server and I need to map URL in this way:

  1. Url from b2b.domain.eu have to be proxied to another server 10.1.0.100 [IT WORKS]

  2. Url from b2b.domain.eu/api have to be proxied to a tomcat api application [IT WORKS]

  3. Url from b2b.domain.eu/decoder have to be proxied to a tomcat decoder application [IT WORKS]

  4. For Url /App1/Shop/home.aspx we need to execute an output filter [IT WORKS]

  5. www.domain.eu and web.domain.eu have to serve wordpress website [IT DON'T WORK] -> Instead the application go to App1 that seems to be default

Below there is my actual configuration. I tried to change it in different ways, change order, etc without any success. Anyone can help me to understand how to reach the expected behaviour?

Thanks in advance

<VirtualHost *:80>
ServerName 10.1.0.101
ServerAlias b2b.domain.eu

ProxyRequests Off
ProxyPreserveHost On

ExtFilterDefine filter1 mode=output \
cmd="/var/www/cgi-bin/filter.pl /tmp/filter.out"

#Root: forward to App1 [OK]
<LocationMatch "^/">
   ProxyPassMatch  http://10.1.0.100/App1
   ProxyPassReverse  http://10.1.0.100/App1
</LocationMatch>

#API: Forward to tomcat (api) [OK]
<LocationMatch "^/api/(.*)">
   ProxyPassMatch   http://localhost:8080/api/$1
   ProxyPassReverse http://localhost:8080/api/$1
</LocationMatch>

#Decoder: Forward to tomcat (decoder) [OK]
<LocationMatch "^/decoder(.*)">
   ProxyPassMatch   http://localhost:8080/decoder$1
   ProxyPassReverse http://localhost:8080/decoder$1
</LocationMatch>

#App1 with filter execution [OK]
<LocationMatch "^/App1/Shop/home.aspx(.*)">
   ProxyPassMatch   
     http://10.1.0.100/App1/Shop/home.aspx$1
   ProxyPassReverse 
   http://10.1.0.100/App1/Shop/home.aspx$1

   SetOutputFilter   filter1
</LocationMatch>

#App1 [OK]
<LocationMatch "^/App1(.*)">
   ProxyPassMatch   http://10.1.0.100/App1$1
   ProxyPassReverse http://10.1.0.100/App1$1
</LocationMatch>

</VirtualHost>

#[KO]
<VirtualHost *:80>
   ServerName 10.1.0.101
   ServerAlias www.domain.eu  web.domain.eu
   DocumentRoot /var/www/html/wordpress
</VirtualHost>

[UPDATE 2018/11/28]

I changed configuration as suggested by @tom but these changes didn't resolve issue. Maybe the issue is not in Apache configuration but in our Fortinet 60E because we noticed that adding follow line in a Windows clients in file C:\Windows\System32\drivers\etc\hosts the behaviour is as expected.

10.1.0.101      web.domain.eu

Our DNS is configured to map our public IP. Fortinet forwards the request (without NAT) to Apache Web Server (10.1.0.101) but it seems to remove some information.

fciri
  • 141
  • 6

1 Answers1

1

Both you VirtualHost instances have the same IP + port + ServerName combination. These three items together must uniquely define your virtual host. For name-based virtual hosting the IP address and port number will be the same so you differentiate using the ServerName directive. Don't put an IP address as the ServerName.

<VirtualHost 10.1.0.101:80>
  ServerName b2b.domain.eu
  [...]
</VirtualHost>

<VirtualHost 10.1.0.101:80>
  ServerName www.domain.eu
  ServerAlias web.domain.eu
  [...]
</VirtualHost>

Also read up on the documentation on name-based virtual hosting.

Tommiie
  • 5,627
  • 2
  • 12
  • 46
  • Hi Tom, thank you for you reply. I tried your solution without success but I noticed that if I map "web.domain.eu" on "/etc/hosts" all works fine inner our network (using private address). So the problem is our Router Fortinet 60E that seems that doesn't propagate the host when receives the request to our public IP and forwarded the request to Tomcat using only private IP address – fciri Nov 27 '18 at 10:21
  • That sounds like a DNS issue. Can you ask a new question about that? Share your topology, DNS information etc and we can assist you with that problem as well. – Tommiie Nov 27 '18 at 10:24
  • "if I map "web.domain.eu" on "/etc/hosts" all works fine inner our network (using private address)." -> my solution did indeed work, now it's just a DNS issue that you are bumping into. – Tommiie Nov 27 '18 at 10:24
  • I update the post: now I think the apache configuration it's ok and maybe the issue is related to Fortinet. – fciri Nov 28 '18 at 14:39
  • with Tom's suggestion and a little fix on DNS, all application now are reaches correctly. Thanks! – fciri Nov 28 '18 at 21:04
  • Perfect! Can you please accept my answer then? :-) – Tommiie Nov 29 '18 at 06:01