3

I want to forward a request from one server to another. Here is my problem:

  • hr.example.com - port 80 - Server A
  • support.example.com - port 80 - Server B

All requests on port 80 are forwarded to Server A by the firewall.

So, I want requests for support.example.com to be forwarded from server A to server B. How can I achieve this with Apache?

I followed the answer from here. I added the following code to my apache.conf on Server A but it results in a "500 internal server error".

<VirtualHost *:80>
  ServerName support.example.com    
  LoadModule proxy_module modules/mod_proxy.so    
  ProxyRequests Off
  <Proxy *>
     Require all granted
  </Proxy>    
  ProxyPass / http://IP-ADDRESS-SERVER-B:80/
  ProxyPassReverse / http://IP-ADDRESS-SERVER-B:80/
  <Location />
     Require all granted
   </Location>    
</VirtualHost>

Note: Server A is Windows server 2012 with Apache 2.4

How should I forward these requests properly please?

  • You need to check your error log for the details of this error. You may also need mod_proxy_html. IP-ADDRESS-SERVER-B - Does this serve the content from support.example.com? – MrWhite May 9 '18 at 10:04
  • of course: error.logstated the following:AH01144: No protocol handler was valid for the URL /. If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule It turned out i needed extra module mod_proxy_httpand now it's redirecting correctly to IP-ADDRESS-SERVER-B(which serve content of support.example.com. Only problem now: it displays another webpage running on :80. How can I point it to correct site (ServerNameis already correct`)? – wouter205 May 9 '18 at 11:40
  • 1
    Sorry, I meant mod_proxy_http (mod_proxy_html is another module but is not necessarily "essential"). "it displays another webpage" - if you have multiple vHosts on Server-B then you can't use the server's IP address, you must use the hostname. – MrWhite May 9 '18 at 11:59
  • 1
    Marvelous! It works indeed with the hostname. I'll make a new post with my working apache conf. Thanks! – wouter205 May 9 '18 at 12:14
1

Thanks @MrWhite for giving the correct configuration. I needed extra module mod_proxy_http and to change the IP adress of server-B to the hostname as I have multiple vHosts on :80. Here is the working configuration:

<VirtualHost *:80>
support.example.com 
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so


 ProxyRequests Off
    <Proxy *>
     Require all granted
    </Proxy>

  ProxyPass / http://support.example.com:80/
   ProxyPassReverse / http://support.example.com:80/
  <Location />
       Require all granted
   </Location>


</VirtualHost>

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.