Centos – load mod_proxy and mod_proxy_http modules of apache in centos

apache-2.2centosreverse-proxy

here's my system:

CentOS release 5.6 (Final)
Server version: Apache/2.2.21 (Unix)
Cpanel::Easy::Apache v3.7.2 rev9999

I am trying to create a reverse proxy to load files from another server onto my server, as I explained here a while ago:

use a domain on one server to load an application on another server

However, at the time I wrote that I was thinking I would be using ubuntu but now found out it will be centos. I was going to follow this article:

http://jeffbaier.com/articles/configuring-apache-virtual-hosts-for-nat/

But on this specific line:

"We need to make sure mod_proxy and mod_proxy_http are loaded. If the proxy modules are loaded, you’ll see them listed. If nothing is found, this means you need to create symbolic links from the mods-available folder to the mods-enabled folder."

It explains how to check if those two modules are loaded and if not, how to create symbolic links to load them. However, it explains how to do it on ubuntu.

If I even try to attempt to do that on centos:

cd /etc/apache2/
-bash: cd: /etc/apache2/: No such file or directory

there is no apache2 folder in etc.

So I am trying to figure out how to do it on centos.

thanks for response

Best Answer

In /etc/httpd/conf/httpd.conf make sure you have the following lines enabled (no # infront of them):

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so

This link will probably be useful for you to read too:
http://www.linuxtopia.org/online_books/centos5/centos5_administration_guide/centos5_ch-httpd.html

Worth noting is that CentOS is an openly built version of the RedHat operating system, so any documentation you can find for RedHat 5 would almost always fully apply to CentOS aswell. CentOS 6 is released, btw, so you might also want to think of upgrading!

For Virtualhost configuration; put this in the end of httpd.conf:

NameVirtualHost *:80

<VirtualHost *:80>
  ServerName domain2.com
  DocumentRoot /var/www
  ProxyRequests Off
  Order deny,allow
  Allow from all

  ProxyPass / http://192.168.1.120:8080/
  ProxyPassReverse / http://192.168.1.120:8080/
</VirtualHost>

And see how it works. You'll ofcourse have to change domain2.com for your own domain and 192.168.1.120 for whatever your own infrastructure uses as IP adresses.