You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Melanie Pfefer <me...@yahoo.co.uk> on 2009/04/27 14:20:38 UTC

[users@httpd] alias using Virtual host

Hi

I have the main apache running on port 80.
I built another configuration file to have another apache running on port 8094.

I can access both servers:

http://host
http://host:8094

Now I want to have http://MySecondAlias to redirect to http://host:8094

I added MySecondAlias to DNS and I added these lines in the main apache config

NameVirtualHost *:80

<VirtualHost *:80>
        ServerName MySecondAlias
        ProxyPass / http://localhost:8094/
        ProxyPassReverse / http://localhost:8094/
</VirtualHost>


Now http://host redirects to http://MySecondAlias and I do not want this.

How to fix this situation?

I.e 

Http://host goes to the default apache
http://MySecondAlias goes to the 2nd apache running on 8094

any other alternative is also welcomed.

thanks


      

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


RE: [users@httpd] alias using Virtual host

Posted by Steffen Tronstad <st...@nextgentel.com>.
Use "ServerAlias MyServerAlias" in the other VirtualHost directive, instead of another ServeRName.


-----Opprinnelig melding-----
Fra: Melanie Pfefer [mailto:melanie_pfefer@yahoo.co.uk] 
Sendt: 27. april 2009 14:21
Til: users@httpd.apache.org
Emne: [users@httpd] alias using Virtual host


Hi

I have the main apache running on port 80.
I built another configuration file to have another apache running on port 8094.

I can access both servers:

http://host
http://host:8094

Now I want to have http://MySecondAlias to redirect to http://host:8094

I added MySecondAlias to DNS and I added these lines in the main apache config

NameVirtualHost *:80

<VirtualHost *:80>
        ServerName MySecondAlias
        ProxyPass / http://localhost:8094/
        ProxyPassReverse / http://localhost:8094/
</VirtualHost>


Now http://host redirects to http://MySecondAlias and I do not want this.

How to fix this situation?

I.e 

Http://host goes to the default apache
http://MySecondAlias goes to the 2nd apache running on 8094

any other alternative is also welcomed.

thanks


      

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] alias using Virtual host

Posted by André Warnier <aw...@ice-sa.com>.
Melanie Pfefer wrote:
> Hi
> 
> I have the main apache running on port 80.
> I built another configuration file to have another apache running on port 8094.
> 
> I can access both servers:
> 
> http://host
> http://host:8094
> 
> Now I want to have http://MySecondAlias to redirect to http://host:8094
> 
> I added MySecondAlias to DNS and I added these lines in the main apache config
> 
Listen 80
Listen 8084

> NameVirtualHost *:80
> 
 > <VirtualHost *:80>
 >         ServerName localhost
	....
 > </VirtualHost>

> <VirtualHost *:80>
>         ServerName MySecondAlias
>         ProxyPass / http://localhost:8094/
>         ProxyPassReverse / http://localhost:8094/
> </VirtualHost>

 > NameVirtualHost *:8084
 >
 > <VirtualHost *:8084>
 >         ServerName localhost
	....
 > </VirtualHost>

Explanation:
For each listen port, the first-defined VirtualHost section acts as the 
"default host".  That means that whenever Apache receives a request on 
that port, and the hostname of that request does not match any of the 
ServerName directives of the <VirtualHost> sections for that port, it 
will use the first <VirtualHost> section to answer the request.
(So basically, for that first <VirtualHost> section, it does not matter 
which ServerName you put in it).
In other words, if your section
<VirtualHost *:80>
         ServerName MySecondAlias
         ProxyPass / http://localhost:8094/
         ProxyPassReverse / http://localhost:8094/
</VirtualHost>
was the only one, then it was also the default one, and it was catching 
*all* the requests (no matter if they said "host" or "www.google.com" or 
"MySecondAlias" or whatever).

Another tidbit : you mentioned "a 2d Apache" somewhere.  There is only 
*one* Apache, with children (or threads) all identical.  The "parent" 
Apache only catches incoming connections, and distributes them to 
whatever child happens to be inactive.  Each child can answer any 
request, to any VirtualHost.  It just temporarily "takes the 
personality" of the selected VirtualHost to answer that request.
When it's done with that request, it becomes neutral again, and can 
answer next any request for any VirtualHost again.

To use an image, think of it as one "father Apache" who just distributes 
the work among his 20 "twin children Apache", all of them who are very 
good actors, and can temporarily impersonate any VirtualHost, for just 
one request.


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org