6

I am trying to install Mod_Proxy Apache module on WHM/CPanel CeEntOS Linux Server. Here is system info:

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

The purpose of me installing is so that when on site abc.com, when I click a link to site auto.efg.com (lets pretend its ip address is 192.168.0.101), the browser will load the application on auto.efg.com while mainitaing abc.com on address bar of browser.

So I followed this tutorial:

http://www.hackersgarage.com/install-mod_proxy-apache-module-on-whmcpanel-ceentos-linux-server.html

And so when I finished following it, I was able to do this:

root@ip-xxx-xxx-xxx [/tmp/httpd-2.2.21/modules/proxy]# ls -l           
/usr/local/apache/modules/mod_proxy*

-rwxr-xr-x 1 root root 88708 Jan  5 08:22 /usr/local/apache/modules/mod_proxy.so*
-rwxr-xr-x 1 root root 49654 Jan  5 08:23 /usr/local/apache/modules/mod_proxy_connect.so*
-rwxr-xr-x 1 root root 73196 Jan  5 08:23 /usr/local/apache/modules/mod_proxy_http.so*

Now after I followed those instructions and tried to restart the server, I got the following error:

/etc/init.d/httpd restart
httpd: Syntax error on line 35 of /usr/local/apache/conf/httpd.conf: module proxy_module is built-in and can't be loaded

You see, that occured because I had loaded the module for proxy_module,. proxy_http_module in httpd.conf, so I commented them out in /usr/local/apache/conf/httpd.conf:

# LoadModule proxy_module   modules/mod_proxy.so
# LoadModule proxy_http_module  modules/mod_proxy_http.so
# LoadModule proxy_connect_module modules/mod_proxy_connect.so

Now that error went away.

And my virtual host setting looks like this:

<VirtualHost 50.63.53.79:80>
    ServerName abc.com
    ServerAlias www.abc.com
    DocumentRoot /home/eagl0028/public_html
    ServerAdmin [email protected]
    ## User eagl0028 # Needed for Cpanel::ApacheConf
    <IfModule mod_suphp.c>
      suPHP_UserGroup eagl0028 eagl0028
    </IfModule>
    <IfModule !mod_disable_suexec.c>
      SuexecUserGroup eagl0028 eagl0028
    </IfModule>
    ProxyRequests Off
    <Proxy *>
      Order deny,allow
      Allow from all
    </Proxy>
    ProxyPreserveHost On
    ProxyPass / http://192.168.0.101/
    ProxyPassReverse / http://192.168.0.101/
    CustomLog /usr/local/apache/domlogs/abc.com-bytes_log "%{%s}t %I .\n%{%s}t %O ."
    CustomLog /usr/local/apache/domlogs/abc.com combined
    ScriptAlias /cgi-bin/ /home/eagl0028/public_html/cgi-bin/
</VirtualHost>

However, when I run:

 service httpd stop
 service httpd start

And then post to a relative url:

<form accept-charset="UTF-8" action="/users/sign_in" class="user_new" id="user_new" method="post">

Im expecting it to post to 192.168.0.101 but it doesnt. I check the 192.168.0.101 server logs and no sign of a request coming in. All that occurs is a 404 not found error with the url on top being abc.com/users/sign_in

5
  • 1
    You have two questions wrapped up in one: "What's wrong with my proxy?" (Everything up to All I notice is that when I try "apachectl stop"…), and "What's messed up with my Apache configuration syntax?" (everything from All I notice on...). Please split these up - you appear to be conflating two unrelated problems...
    – voretaq7
    Jan 5, 2012 at 19:38
  • I provided "All I notice on" as some background to perhaps indicate a source of the other problem. Jan 5, 2012 at 21:16
  • Please only ask one question at once. Delete the other question.
    – hakre
    Jan 6, 2012 at 14:59
  • I updated the question to only ask one question. basically the question is when posting form, it is not sending the request to the other server, despite proxy in place. Jan 6, 2012 at 15:04
  • Does the 404 error show up in Apache's logs on the abc.com server?
    – Chris S
    Feb 14, 2012 at 15:15

2 Answers 2

1

Your VirtualHost has an IP address+port pair of 50.63.53.79:80. This may sound like obvious advice, but if the server has multiple IP addresses or ports that it's listening on, make sure that your browser is in fact hitting that IP address and port. If the POST is hitting port 443 or similar, this virtualhost will not be the one that gets used. This would explain why nothing shows up in the log. Check the main server log, to see if your request went there. If you're running your test from the local network and it's hitting a local network IP address, that would definitely do it.

Similar behavior can be triggered if you have this configuration in an include file that is not actually being used.

In both cases, running the httpd binary by hand with the -S parameter (make sure you're including all of the necessary parameters from the currently running apache process that you see in the process table) will show you all of the defined virtual hosts and help you spot ones that are missing, or other address+port pairs that might be catching the traffic.

You can configure a virtualhost to listen to all IP addresses by using a * instead of the IP address.

<VirtualHost *:80>

You can also explicitly configure multiple IP Addresses

<VirtualHost 50.63.53.79:80 192.168.0.101:80>
0

The href of http://auto.efg.com/users/sign_in/ is sending your browser away from the proxy - it's not Apache's job to make sure that every link on the page keeps your browser talking to the proxy. (There are some third party modules that alter the URLs on the page in transit, but they won't work against anything except links in flat HTML)

Can you alter the link to leave the scheme and host intact?

<a href="/users/sign_in/">clicky</a>
14
  • I change the link to be the relative url you show above, however, when clicking on it it displays not found page: Error 404 - Page not found! Jan 5, 2012 at 20:04
  • @JohnMerlino Err, sorry - is that the right URL? You've configured your proxy to send requests from / to /users/sign_in/ - so a request to the proxy for /users/sign_in/ would go to /users/sign_in/users/sign_in/. Which sections of the site did you mean to proxy? Jan 5, 2012 at 20:09
  • I changed it back to the ip address, and got rid of the /users/sign_in part and still the same problem Jan 5, 2012 at 21:10
  • @JohnMerlino So what's the URL in your browser when you get the 404 response at this point? (and did you restart Apache after you made the config change?) Jan 5, 2012 at 21:30
  • the url in browser is the site url with "/users/sign_in" appended to it. So basically what I see is abc.com/users/sign_in . Now that actually is what I want to see, but I want the files from auto.efg.com loaded, so rather than seeing auto.efg.com/users/sign_in (which currently works), I want to see abc.com/users/sign_in. Jan 5, 2012 at 22:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .