LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Apache VirtualHost QS (https://www.linuxquestions.org/questions/linux-server-73/apache-virtualhost-qs-741599/)

helptonewbie 07-21-2009 01:48 AM

Apache VirtualHost QS
 
Hi all,

Just wonderin if in apache its possible to do something like have virtual hosts set-up as follows:-

Code:

<VirtualHost 192.168.0.1>   
DocumentRoot /www/something

ScriptAlias /cgi-bin /www/something/cgi-bin

  <Directory /www/something>
    Options FollowSymLinks MultiViews
    AllowOverride All
  </Directory>
 
</VirtualHost>

<VirtualHost 192.168.0.2>   
DocumentRoot /www/somethingelse

ScriptAlias /cgi-bin /www/somethingelse/cgi-bin

  <Directory /www/somethingelse>
    Options FollowSymLinks MultiViews
    AllowOverride All
  </Directory>
 
</VirtualHost>

Thus i'm trying to make two default apache virtualhosts as it were... in such a way that if a request goes to one IP address or the other... thats the document route it goes to... would the above work without a ServerName directive? So that both virtual hosts can catch requests on the specific IP and then send it to the corresponding DocRoot

Sound Viable??

Cheers,
M

jhwilliams 07-21-2009 02:22 AM

Quote:

If no ServerName is specified, then the server attempts to deduce the hostname by performing a reverse lookup on the IP address. If no port is specified in the ServerName, then the server will use the port from the incoming request. For optimal reliability and predictability, you should specify an explicit hostname and port using the ServerName directive.

If you are using name-based virtual hosts, the ServerName inside a <VirtualHost> section specifies what hostname must appear in the request's Host: header to match this virtual host.

See the description of the UseCanonicalName directive for settings which determine whether self-referential URL's (e.g., by the mod_dir module) will refer to the specified port, or to the port number given in the client's request.
The above from here:
http://httpd.apache.org/docs/2.0/mod...tml#servername

helptonewbie 07-21-2009 11:35 AM

Yea thanks, i had already read that of course. And can't see that it really answers my question, reverse DNS wouldn't really work in the instance i'm talking about... perhaps you can explain it a bit more... i'm looking more at IP based virtual hosts in the hope that i can achieve basically setting lots of DNS names at one VH and another load of DNS names at another VH and then depending on which DNS name typed in depends of course on what IP address you hit, and then depending on the IP address hit i'm hoping that any request to that IP address will be taken to it relevent DocRoot... i guess this is something i could just test with out asking here.... but i thought it would be best to try and understand more on what i'm trying to achieve because i couldn't see anything on the apache docs and other places that relate to what i'm trying to achieve.

routers 07-21-2009 11:39 PM

do you have those ip added to your apache server network interface ?

helptonewbie 07-22-2009 04:34 AM

Quote:

do you have those ip added to your apache server network interface ?
Erm, currently no... they are just examples... i would have something along those lines if people say its a feasibly possible to do what i'm trying to achieve. IP addresses and it would be a very small amount so no chance of exhausting the system... would be added using IP alias addresses probably.

Cheers,
M

routers 07-22-2009 05:34 AM

yeah with lan ip set in the container you can have many many web use with
ip , but for me better you named base , but if still need to use ip then
the ip also must be aliases in the NIC


in the lan also you can use named base provided you have your local dns
set point domain to local ip and another part is in /etc/hosts in that
server itself

helptonewbie 07-22-2009 11:33 AM

Quote:

Originally Posted by routers (Post 3616203)
yeah with lan ip set in the container you can have many many web use with
ip , but for me better you named base , but if still need to use ip then
the ip also must be aliases in the NIC


in the lan also you can use named base provided you have your local dns
set point domain to local ip and another part is in /etc/hosts in that
server itself

We are currently using name based but this is not ideal when you start to get so many files, especially when they all point to the same place. Thats why it would be nice if requests going to one IP could all goto one DocRoot and it accepting all DNS / hostnames on that IP. And same on the other regardless of what hostname is set in the header because its been received on that other IP address then the Virtualhost should send it to the other DocRoot.

Without the need for any DNS entries anywhere... i'd have thought this was possible but maybe i'm wrong? Its certainly possible if setting up a second apache instance or whatever because you can just set the _default_ and then send all requests to that. But i'm trying to get a similar thing done without needing a second apache instance but still catching everything to either one or the other DocRoot?

Cheers,
M


All times are GMT -5. The time now is 01:57 PM.