LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (http://www.linuxquestions.org/questions/linux-server-73/)
-   -   Apache Vhost with reverse proxy and redirection (http://www.linuxquestions.org/questions/linux-server-73/apache-vhost-with-reverse-proxy-and-redirection-780316/)

volga629 01-06-2010 11:21 AM

Apache Vhost with reverse proxy and redirection
 
Here my setup of Apache
I have two virtual hosts on separate IP and on both I am using port :80 one is main website domain.name and another webmail.domain.name.
And to get full link path i am using index.html with redirection derectives. My question how I can setup each Vhost to he is own redirection derictive to set two full link like:
when type webmail.domainname -----> redirect to webmail.domainname/horde/imp/file.php
and www.domainname ------> redirect to www.domainname/csr/
Right now working only one of this Vhosts, just problem to separate them when I type www.domainname -----> apache redirect to webmail.domainname.

########################
index.html

<html>
<head>
<title>WebSite</title>
<meta http-equiv="REFRESH" content="1;url=http://www.domainname/csr/"></HEAD>
<BODY>REDIRECTION</BODY>
</HTML>
################################################
index.html

<html>
<head>
<title>WebSite</title>
<meta http-equiv="REFRESH" content="1;url=http://www.mail.domainname/horde/"></HEAD>
<BODY>REDIRECTION</BODY>
</HTML>

################################################
Listen xxx.xxx.xxx.xxx:80

Alias /horde /dire/ctory/horde/horde

<VirtualHost *:*>
DocumentRoot /dire/ctory/horde
ServerName webmail.domainname
ServerAlias webmail
ProxyPreserveHost On
ProxyRequests Off
ProxyPass horde/ http://webmail.domainname/horde
ProxyPassReverse horde/ http://webmail.domainname/horde
#AccessFileName .htaccess


#Redirect permanent / http://www.webmail.domainname/horde/
#RewriteEngine on
#RewriteRule horde/ http://www.webmail.domainname/horde [R]
#RewriteCond %{HTTP_HOST} ^www.webmail.domainname$
#RewriteRule ^(.*)$ http://www.webmail.domainname/horde$1 [R=301,L]
</VirtualHost>

#############################################
Listen xxx.xxx.xxx.xxx:80

#Alias /csr /dire/ctory/mainweb/csr

#<VirtualHost www.domainname>
# DocumentRoot /dire/ctory/mainweb/csr
# ServerName domainname
# ServerAlias www.sdomainname
#ProxyPreserveHost On
# ProxyRequests Off
# ProxyPass /csr/ http://domainname/csr
# ProxyPassReverse /csr/ http://domainname/csr
#Redirect permanent /csr http://www.domainname/csr
#AccessFileName .htaccess
</VirtualHost>
#############################################

Any help welcome.
Thank you ahead.

Elemecca 01-11-2010 11:15 PM

EDIT: See my next post.

Also, when you put files in a post you should put them in code blocks like "[code]file contents...[/code]". That way they'll end up in a separate monospaced block like this:
Code:

file contents...

Elemecca 01-11-2010 11:43 PM

My understanding of your situation is thus: You have a server with two IPs. You would like to use IP-based virtual hosting to host two sites -- a Horde webmail and your main site. You would like 'webmail.example.com' to be the Horde and 'www.example.com' to be your main site. You want each to appear at the root of its respective URL. You do not want to access Horde as 'www.example.com/horde' or your main site as 'webmail.example.com/csr'. Horde and your main site are installed in subdirectories of the same directory, for instance '/var/www/horde' and '/var/www/csr'. Is this correct?

If my above assumptions are correct, the Apache configuration below should do what you want. Replace 'example.com' with your domain name, '/var/www' with the directory containing your sites, 'xxx.xxx.xxx.xxx' with the IP you want to serve Horde from, and 'yyy.yyy.yyy.yyy' with the IP you want to serve your main site from.
Code:

Listen xxx.xxx.xxx.xxx:80
Listen yyy.yyy.yyy.yyy:80

<VirtualHost xxx.xxx.xxx.xxx:80>
    ServerName webmail.example.com

    DocumentRoot /var/www/horde
</VirtualHost>

<VirtualHost yyy.yyy.yyy.yyy:80>
    ServerName example.com
    ServerAlias www.example.com

    DocumentRoot /var/www/csr
</VirtualHost>

There is no need for any redirection, proxying, or URL rewriting.

volga629 01-13-2010 03:30 AM

Thank you on replay, you all most right, but situation more complicated.
I implemented two think for first virtual host is just redirection with index.html from port 80 to port 80 external and for this i used revers proxy. And second one is was implemented local on port 80 with reverse proxy on port 80 and permanent redirection to 443. And 443 just reverse proxy from 443 to 443 with index.html redirection to link path with i need to make no hassle to clients.
You can visit www.skillsearch.ca and www.webmail.skillsearch.ca and you can see the all redirection yourself and how look all links.


All times are GMT -5. The time now is 07:35 PM.