LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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-02-2010, 10:05 AM   #1
Skaperen
Senior Member
 
Registered: May 2009
Location: center of singularity
Distribution: Xubuntu, Ubuntu, Slackware, Amazon Linux, OpenBSD, LFS (on Sparc_32 and i386)
Posts: 2,684
Blog Entries: 31

Rep: Reputation: 176Reputation: 176
Apache virtual hosts with IP address


What is the (officially) proper way to configure Apache so that a given IP address can have two or more virtual host names, each going to different distinct configurations (e.g. with different DocumentRoot, Alias, etc), and also do this for the IP address so that it goes to a designated configuration rather than defaulting to the first or a random host name?

Apache documentation does not appear to address this. If so, it has it hidden in a non-obvious place.
 
Old 07-02-2010, 11:59 AM   #2
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 250Reputation: 250Reputation: 250
What like this or this ?
 
Old 08-09-2010, 02:26 PM   #3
Skaperen
Senior Member
 
Registered: May 2009
Location: center of singularity
Distribution: Xubuntu, Ubuntu, Slackware, Amazon Linux, OpenBSD, LFS (on Sparc_32 and i386)
Posts: 2,684

Original Poster
Blog Entries: 31

Rep: Reputation: 176Reputation: 176
No actual IP based configuration examples are there. All the examples are based on domain names. Do you have an example based on an IP address, preferrably for both IPv4 and IPv6?
 
Old 08-09-2010, 10:10 PM   #4
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 250Reputation: 250Reputation: 250
I suggest you read the links again.
 
Old 08-10-2010, 07:45 AM   #5
Skaperen
Senior Member
 
Registered: May 2009
Location: center of singularity
Distribution: Xubuntu, Ubuntu, Slackware, Amazon Linux, OpenBSD, LFS (on Sparc_32 and i386)
Posts: 2,684

Original Poster
Blog Entries: 31

Rep: Reputation: 176Reputation: 176
Those links are going around what I want to do, but not actually doing it. About the only difference is that NameVirtualHost is used to indicate an IP address that uses names. But nothing in either explains how to do BOTH name based AND IP based on the same IP address.

Here is an actual config used on a test machine. It does not work. And I've tried a number of variations on this, all of which do not work. There are many different messages from the variations. I cannot see anything the two documents cover that I haven't tried.

Code:
Listen [fcca::1006]:80
NameVirtualHost [fcca::1006]:80
<VirtualHost [fcca::1006]:80>
        ServerName [fcca::1006]:80
        DocumentRoot /home/pub/fcca::1006
        <Directory /home/pub/fcca::1006/>
                Options +FollowSymLinks
                AllowOverride All
                order allow,deny
                allow from fcc0::/12
        </Directory>
</VirtualHost>
<VirtualHost [fcca::1006]:80>
        ServerName meitner
        DocumentRoot /home/pub/meitner
        <Directory /home/pub/meitner/>
                Options +FollowSymLinks
                AllowOverride All
                order allow,deny
                allow from fcc0::/12
        </Directory>
</VirtualHost>

Last edited by Skaperen; 08-10-2010 at 07:47 AM.
 
Old 08-10-2010, 11:42 AM   #6
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 250Reputation: 250Reputation: 250
Quote:
But nothing in either explains how to do BOTH name based AND IP based on the same IP address.
That's because you can't. Either you do name based OR you do IP based. To do both on the same machine you need more than 1 IP address.
If you only have 1 ip address, then if you access the server using that ip address, you will get directed to the first virtual host. All other virtual hosts need to be accessed by their host and/or domain name.
If you have 2 ip addresses, then the above still applies, but the 2nd ip address will be a host of it's own. You cannot use that ip for further virtual hosts.

Last edited by smoker; 08-10-2010 at 11:49 AM.
 
Old 08-10-2010, 02:29 PM   #7
Skaperen
Senior Member
 
Registered: May 2009
Location: center of singularity
Distribution: Xubuntu, Ubuntu, Slackware, Amazon Linux, OpenBSD, LFS (on Sparc_32 and i386)
Posts: 2,684

Original Poster
Blog Entries: 31

Rep: Reputation: 176Reputation: 176
Well, that is supposed to work. When you enter the IP address on the browser URL, it passes the IP address string in the Host: header in HTTP. For IPv4, Apache is mature and knows how to recognize it. It works in IPv4. Either Apache is not yet IPv6 ready, or there is some special way Apache uses to recognize the IPv6 address. The address comes though the HTTP Host: header like:
Code:
Host: [fcca::1006]
since the address has to be entered that way in the URL. So the ServerName should just take it that way. The question is syntax. Does it need quotes or other special syntax sugar?

Browsers CAN go to hosts both by name and by IP address ... and even by 2 different ways in IPv4 (one like 172.30.16.6 and the other like 2887651334 for the very same address).

Last edited by Skaperen; 08-10-2010 at 02:32 PM.
 
Old 08-10-2010, 02:37 PM   #8
Skaperen
Senior Member
 
Registered: May 2009
Location: center of singularity
Distribution: Xubuntu, Ubuntu, Slackware, Amazon Linux, OpenBSD, LFS (on Sparc_32 and i386)
Posts: 2,684

Original Poster
Blog Entries: 31

Rep: Reputation: 176Reputation: 176
As far as I can tell, this is a bug in Apache, or it's just not IPv6 ready, yet. But it being such a major pain to report bugs on big projects like this, I want to vet out any weird alternatives before reporting it. Using the very latest version of Apache is simply not an option until I get our systems migrated off Ubuntu (and that is still several months away and I also need to get the IPv6 stuff working as part of that).
 
  


Reply



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
reverse dns to find all virtual hosts for an ip address rogerdal Linux - Networking 3 12-24-2011 02:42 PM
apache virtual hosts ramjam Linux - Server 1 09-17-2009 06:15 AM
Virtual Hosts with Apache noripcord7 Linux - Games 1 02-22-2004 10:33 PM
Apache Virtual Hosts quozt Linux - General 3 10-15-2003 09:51 AM
Apache: Virtual hosts pk21 Linux - Software 15 10-08-2002 05:08 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 04:23 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration