500 internal server error when trying to implement reverse proxy under Apache. How do I forward the requests to another server without errors?

14,742

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>
Share:
14,742

Related videos on Youtube

wouter205
Author by

wouter205

Updated on September 18, 2022

Comments

  • wouter205
    wouter205 almost 2 years

    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?

    • wouter205
      wouter205 about 6 years
      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`)?
    • MrWhite
      MrWhite about 6 years
      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.
    • wouter205
      wouter205 about 6 years
      Marvelous! It works indeed with the hostname. I'll make a new post with my working apache conf. Thanks!