LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 01-09-2013, 07:48 AM   #1
kendel
LQ Newbie
 
Registered: Aug 2010
Posts: 14

Rep: Reputation: 0
Apache and mod_proxy


I am running ubunu linux, trying to use a feature to forward a requested domain to a second server on my internal network:

webserver: 192.168.10.160 [router forwards all requests to port 80 here]
mailserver: 192.168.10.180 [has an apache client running]

I installed round cube on the mail server which works if I type http://192.168.10.180/roundcube
I then created a virtual host on the mailserver: (using webmin and on port 81)
Code:
DocumentRoot /var/www/roundcube
ServerName webmail.example.com
ServerAdmin webmaster@webmail.example.com
<Directory /var/www/roundcube>
allow from all
Options +Indexes
</Directory>
I then logged into the webserver and created the proxy:
Code:
ServerName webmail.example.com
ServerAlias webmail
ProxyPreserveHost on
    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>
ProxyPass / http://192.168.10.180:81/
ProxyPassReverse / http://192.168.10.180:81/
    <Location />
        Order allow,deny
        Allow from all
    </Location>
I then logged into the DNS, and created a subdomain "A" record webmail.example.com to External IP
But when you try to goto webmail.example.com it only goes to www.example.com webpage. Can anyone tell me what the possible problem is?
 
Old 01-09-2013, 07:54 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,384

Rep: Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963
that httpd config excerpt isn't complete. Shouldn't it be within a virtualhost declaration? You'll certainly need that if you've multipkle site names on the single box. And to turn virtualhosting on in the first place.
 
Old 01-09-2013, 07:58 AM   #3
kendel
LQ Newbie
 
Registered: Aug 2010
Posts: 14

Original Poster
Rep: Reputation: 0
The code you are referring to is
<VirtualHost *:80>
</VirtualHost>
and yes I did try that and got an error, so I went back and looked at all the domains on webmin with virtual host and none of them had the opening and closing codes, I assume webmin is already resolving them somehow (magically). The other domains on my webserver work perfectly. Trying to resolve the proxy to the mailserver has been unsuccessful.
 
Old 01-09-2013, 08:10 AM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,384

Rep: Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963
well I don't use toosl like webmin, post the entire apache config as apache loads them, and it should make much more sense.
 
Old 01-09-2013, 08:22 AM   #5
kendel
LQ Newbie
 
Registered: Aug 2010
Posts: 14

Original Poster
Rep: Reputation: 0
Wow I guess it does resolve them, but in this is the file /etc/apache2/sites-available/webmail.lampxserver.com.conf
Code:
<VirtualHost *:80>
ServerName webmail.example.com
ServerAlias webmail
ProxyPreserveHost on
    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>
ProxyPass / http://192.168.10.180:81/
ProxyPassReverse / http://192.168.10.180:81/
    <Location />
        Order allow,deny
        Allow from all
    </Location>
</VirtualHost>
 
Old 01-09-2013, 10:28 AM   #6
Ramurd
Member
 
Registered: Mar 2009
Location: Rotterdam, the Netherlands
Distribution: Slackwarelinux
Posts: 548

Rep: Reputation: 74
So; You're running the VirtualHost webmail.example.com;
If people within your network go to that url, they'll resolve the machine your VH is running on.

With the ProxyPass you proxy the traffic to 192.168.10.180:81 (which is NOT an external IP ), so: are you sure you're proxying towards the correct host?
 
Old 01-09-2013, 12:18 PM   #7
kendel
LQ Newbie
 
Registered: Aug 2010
Posts: 14

Original Poster
Rep: Reputation: 0
I am not sure I understand what you are saying. From my understanding of proxypass it is suppose to forward traffic of a domain to the server running the services. http://httpd.apache.org/docs/2.2/mod/mod_proxy.html
From what the example shows me, I use the proxy to forward to the internal IP serving the particular domain.

webserver is called web.example.com
mailserver is called mail.example.com

Do you mean I am suppose to use the hostname rather than the alias?

I verified that going to the internal ip apache server works, (also changed the files around to make sure the destination server works). I have a theory the problem stems from the webserver settings, but I am unable to verify

Last edited by kendel; 01-09-2013 at 12:54 PM.
 
Old 01-09-2013, 02:35 PM   #8
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,384

Rep: Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963
the vhost settings seem OK to me, and if the back end server was wrong, it wouldn't be redirecting anywhere else, you'd be getting an HTTP 503 error I think.

so on the webserver box, run this:

curl -v http://192.168.10.160 -H "Host: webmail.example.com"

and that should show you the web page from the webmail server. If not, paste the output here and we'll hopefully be able to see a little more from it. Can you confirm that named based vhosts are enabled? there should be a "NameVirtualHost *:80" directive in the main config somewhere.
 
Old 01-09-2013, 05:46 PM   #9
kendel
LQ Newbie
 
Registered: Aug 2010
Posts: 14

Original Poster
Rep: Reputation: 0
Code:
* About to connect() to 192.168.10.160 port 80 (#0)
*   Trying 192.168.10.160... connected
> GET / HTTP/1.1
> User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zli                                                                                                                     b/1.2.3.4 libidn/1.23 librtmp/2.3
> Accept: */*
> Host: webmail.example.com
>
< HTTP/1.1 200 OK
< Date: Wed, 09 Jan 2013 23:43:31 GMT
< Server: Apache/2.2.22 (Ubuntu)
< Last-Modified: Tue, 08 Jan 2013 03:29:29 GMT
< ETag: "860b0d-100-4d2be8dacc0d6"
< Accept-Ranges: bytes
< Content-Length: 256
< Vary: Accept-Encoding
< Content-Type: text/html
< X-Pad: avoid browser bug
<
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>EXAMPLE.COM</title>
<meta http-equiv="REFRESH" content="0;url=http://www.example.com"></HEAD>
<BODY>
Please wait while we redirect you to our site.
</BODY>
</HTML>
* Connection #0 to host 192.168.10.160 left intact
* Closing connection #0

Ok it seems to be connecting to the webserver rather than the mailserver.... What would cause that? Also I didn't know how to check the vhost.
 
Old 01-10-2013, 02:38 AM   #10
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,384

Rep: Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963
by checking the vhost I just meant the overall httpd config file for that line. Certainly looks clear that the virtualhost is not being used. Could the virtual name be defined twice maybe?? the *ENTIRE* config would be useful.
 
Old 01-10-2013, 04:19 AM   #11
kendel
LQ Newbie
 
Registered: Aug 2010
Posts: 14

Original Poster
Rep: Reputation: 0
Which file the httpd.conf or apache2.conf? Amm here a 00-default.conf
 
Old 01-10-2013, 04:21 AM   #12
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,384

Rep: Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963
well they can be called different things depending on the system you're running, it'd be httpd.conf or apache2.conf, but sure why you'd have both though. If in doubt, post them all.
 
Old 01-11-2013, 03:09 PM   #13
kendel
LQ Newbie
 
Registered: Aug 2010
Posts: 14

Original Poster
Rep: Reputation: 0
I just wanted to thank you, I solved it and the solution was much simpler and well overlooked. The control panel created the domain but used a "*" wild card conf file which basically kept sending everything back to the main domain. After I fixed it to "www" it still didnt work, I had to change all the internal addresses back to port 80. So now everything works on port 80.

Original: Reverseproxy http://192.168.0.180:81/
default: Reverproxy http://192.168.0.180/

I had apache on the mail server listen to port 81, but now I defaulted it back to port 90. My last question before I sign off is, does it matter that all the apache instances among the servers are listening to port 80, will that in the future cause any possible conflicts? Or should I find out why it does not work on port 81, even though I added the Listen 81 to the conf file of apache.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Load Balancing - ipvsadm with apache (mod_proxy) to another apache not working romeo_tango Linux - Server 1 01-12-2012 03:21 AM
Apache mod_proxy and virtualhost dexznrl Linux - Server 1 11-03-2010 05:58 PM
Apache mod_proxy log mahmoud Linux - Software 1 06-07-2010 01:54 AM
Apache + Mod_proxy ProxyPass paul_mat Linux - Networking 2 04-14-2006 08:57 PM
Apache 1.3 mod_proxy no cache mago Linux - Software 0 04-07-2006 12:39 PM


All times are GMT -5. The time now is 04:37 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration