Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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?
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>
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.
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).
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).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.