LinuxQuestions.org
Help answer threads with 0 replies.
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 07-21-2009, 01:48 AM   #1
helptonewbie
Member
 
Registered: Aug 2006
Location: England Somewhere
Distribution: Mandriva, PCLinuxOS, Karoshi, Suse, Redhat, Ubuntu
Posts: 517

Rep: Reputation: 39
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
 
Old 07-21-2009, 02:22 AM   #2
jhwilliams
Senior Member
 
Registered: Apr 2007
Location: Portland, OR
Distribution: Debian, Android, LFS
Posts: 1,168

Rep: Reputation: 206Reputation: 206Reputation: 206
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

Last edited by jhwilliams; 07-21-2009 at 02:23 AM.
 
Old 07-21-2009, 11:35 AM   #3
helptonewbie
Member
 
Registered: Aug 2006
Location: England Somewhere
Distribution: Mandriva, PCLinuxOS, Karoshi, Suse, Redhat, Ubuntu
Posts: 517

Original Poster
Rep: Reputation: 39
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.
 
Old 07-21-2009, 11:39 PM   #4
routers
Member
 
Registered: Aug 2005
Location: Malaysia - KULMY / CNXTH
Distribution: Slackware, Fedora, FreeBSD, Sun O/S 5.10, CentOS
Posts: 749
Blog Entries: 6

Rep: Reputation: 74
do you have those ip added to your apache server network interface ?
 
Old 07-22-2009, 04:34 AM   #5
helptonewbie
Member
 
Registered: Aug 2006
Location: England Somewhere
Distribution: Mandriva, PCLinuxOS, Karoshi, Suse, Redhat, Ubuntu
Posts: 517

Original Poster
Rep: Reputation: 39
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
 
Old 07-22-2009, 05:34 AM   #6
routers
Member
 
Registered: Aug 2005
Location: Malaysia - KULMY / CNXTH
Distribution: Slackware, Fedora, FreeBSD, Sun O/S 5.10, CentOS
Posts: 749
Blog Entries: 6

Rep: Reputation: 74
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
 
Old 07-22-2009, 11:33 AM   #7
helptonewbie
Member
 
Registered: Aug 2006
Location: England Somewhere
Distribution: Mandriva, PCLinuxOS, Karoshi, Suse, Redhat, Ubuntu
Posts: 517

Original Poster
Rep: Reputation: 39
Quote:
Originally Posted by routers View Post
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
 
  


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
Apache -VirtualHost davidhk Debian 7 08-19-2005 12:33 PM
Virtualhost setup on apache 2 notmatt Debian 2 10-28-2004 01:05 PM
Help with Apache <VirtualHost> please. smakkythecamel Linux - Networking 2 06-12-2003 07:15 PM
apache virtualhost jonfa Linux - Networking 5 08-12-2002 06:07 PM


All times are GMT -5. The time now is 12:49 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