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 Code:
ServerName webmail.example.com 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? |
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.
|
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. |
well I don't use toosl like webmin, post the entire apache config as apache loads them, and it should make much more sense.
|
Wow I guess it does resolve them, but in this is the file /etc/apache2/sites-available/webmail.lampxserver.com.conf
Code:
<VirtualHost *:80> |
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 :p), so: are you sure you're proxying towards the correct host? |
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 |
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. |
Code:
* About to connect() to 192.168.10.160 port 80 (#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. |
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.
|
Which file the httpd.conf or apache2.conf? Amm here a 00-default.conf
|
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.
|
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. |
All times are GMT -5. The time now is 11:48 PM. |