logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Apache Reverse Proxy Support - Config Issue
Author
igrummett



Joined: 06 Jun 2020
Posts: 4
Location: Sydney

PostPosted: Sun 29 Aug '21 11:43    Post subject: Apache Reverse Proxy Support - Config Issue Reply with quote

I have a strange issue with my webserver configuration using Apache and reverse proxy.
3 Servers

1. Server 1 (http://192.168.0.31) - Gateway server running Windows 10 and WAMP to act as gateway
2. Server 2 (http://192.168.0.7) – WAMP Server – Running Windows 10 and WAMP hosting a number of test sites and served via Server 1 - Gateway_Server
3. Server 3 (http://192.168.0.65) - IIS_Server – Running Windows 10 and IIS to server .net application via Server 1 – Gateway Server.

Most of my configuration is working apart from one part.
Servers 1 & 2 are working correctly with all sites served correctly. The problem I have is Server 3.
Server 3 Summary
The .net application is working correctly and can be accessed via localhost.
The .net application is working correctly and accessible externally IF I access directly and not via Server 1 – Gateway server.
As everything is working on Server 3 it leads me to think the issue is with Server 1 configuration.


This is the httpd.vhosts.conf for Server 1
__________________________________________________
#Virtual Hosts on HTTPD-vhosts.conf - working fine

<VirtualHost *:80> - working correctly
ServerName localhost
ServerAlias localhost
DocumentRoot "${INSTALL_DIR}/www/"
<Directory "${INSTALL_DIR}/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>


#localhost for demo on Server 1 -working correctly
<VirtualHost *:80>
ServerName local.demo
DocumentRoot "c:/wamp64/www/demo"
<Directory "c:/wamp64/www/demo/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>

#demo.myexample.com on Server 1 - working correctly
<VirtualHost *:80>
ServerName demo.myexample.com
DocumentRoot "c:/wamp64/www/demo"
<Directory "c:/wamp64/www/demo/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>

#Site 1 Hosted on Server 2 - working correctly
<VirtualHost *:80>
ServerName site1.example.com
DocumentRoot "c:/wamp64/www/site1"
<Location />
ProxyPass http://192.168.0.7/site1/
ProxyPassReverse http://192.168.0.7/site1/
AllowOverride All
Require all granted
</Location>
<Directory "c:/wamp64/www/site1/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>

#.net App Hosted on Server – NOT WORKING
<VirtualHost *:80>
ServerName netapp.anotherexample.com
<Location />
ProxyPass http://192.168.0.65
ProxyPassReverse http://192.168.0.65/
AllowOverride All
Require all granted
</Location>
DocumentRoot "C:/netapproot/netapp"
<Directory "C:/netapproot/netapp/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>


_______________________________


Help Required
When I try and access the site I get
Not Found
HTTP Error 404. The requested resource is not found.

I do not understand why, given the net app is working is does not work with this configuration.
As explained:-
• I am able to access Server 3 via localhost and the internal IP address from Server 1
• I am able to access Server 3 externally if I access directly and not via Server 1. I do this by forwarding all web traffic 192.168.0.65 and not 192.168.0.7
Any thoughts much appreciated.
Crying or Very sad
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7373
Location: Germany, Next to Hamburg

PostPosted: Sat 04 Sep '21 22:31    Post subject: Reply with quote

Anything about this in the access log? In the error log? In the windows event log?

You may add an extra log only for that vhost and increase the log level to see any possible errors.
Back to top
tangent
Moderator


Joined: 16 Aug 2020
Posts: 348
Location: UK

PostPosted: Sat 04 Sep '21 23:27    Post subject: Reply with quote

I think you've been inconsistent with your proxy logic in the virtual host connecting to server 3.

See https://httpd.apache.org/docs/current/mod/mod_proxy.html#proxypass and the comment:
    If the first argument ends with a trailing /, the second argument should also end with a trailing /, and vice versa. Otherwise, the resulting requests to the backend may miss some needed slashes and do not deliver the expected results.
I'd consider you're missing a trailing / on the ProxyPass directive, which should be:
Code:
ProxyPass http://192.168.0.65/
ProxyPassReverse http://192.168.0.65/

In addition to James' recommendation about the access and error logs, I'd also enable tracing the browser traffic. If using Chrome or Firefox, open Developer Tools with SHIFT+CTRL+I and capture the network traffic whilst trying to load the site.

A combination of both client and server side logs should help located where the problem lies.
Back to top


Reply to topic   Topic: Apache Reverse Proxy Support - Config Issue View previous topic :: View next topic
Post new topic   Forum Index -> Apache