You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by "Walter H." <wa...@mathemainzel.info> on 2017/11/13 13:18:33 UTC

[users@httpd] Strrange behavior of VirtualHosts in Apache (Apache 2.2.15 - CentOS6)

Hello,

there is a short explanation about virtual hosts in Apache ...
https://wiki.centos.org/TipsAndTricks/ApacheVhostDefault

the `hostname` gives a different donmain name than what should be hosted ...
e.g.  `hostname` is  host.example.org and the domain to be hosted is
example.com, so I did this:

<VirtualHost 1.2.3.4:80>
ServerName host.example.org
DocumentRoot /var/www/default
</VirtualHost>

# used to get let's encrypt for the mail server
<VirtualHost 1.2.3.4:80>
ServerName mail.example.org
ServerAlias smtp.example.org
DocumentRoot /var/www/mail
</VirtualHost>

<VirtualHost 1.2.3.4:80>
ServerName www.example.com
DocumentRoot /var/www/domain
</VirtualHost>

<VirtualHost 1.2.3.4:80>
ServerAlias *.example.com
DocumentRoot /var/www/catchall
</VirtualHost>

the DocumentRoot directories are empty,
only in /var/www/default I have a PHP script:  host.php
<?php
header( "Content-type: text/plain" );
printf( "Host: '%s'\n", $_SERVER['HTTP_HOST'] );
?>

now the strange behavior;

http://mail.example.org/ <-- works
http://smtp.example.org/ <-- doen't work
http://smtp.example.org/host.php <-- gives the HTTP_HOST (PHP-script),
                                     but why?

http://www.example.com/  <-- works
http://hello.example.com/ <-- doesn't work
http://hello.example.com/host.php <-- gives the HTTP_HOST (PHP-script),
                                      but why?

doesn't work does mean, that access/errors are logged in a logfile of a
wrong virtual host ...

where is my mistake?

is it problematic, if some virtual hosts have different IPv6 addresses but
the same IPv4 address?

Thanks,
Walter



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Strrange behavior of VirtualHosts in Apache (Apache 2.2.15 - CentOS6)

Posted by Eric Covener <co...@gmail.com>.
Since you said 2.2, I assume you also have NameVirtualHost 1.2.3.4:80?

> http://www.example.com/  <-- works
> http://hello.example.com/ <-- doesn't work
> http://hello.example.com/host.php <-- gives the HTTP_HOST (PHP-script),
>                                       but why?

HTTP_HOST is just the clients Host: header so this is not too unusual.

>
> doesn't work does mean, that access/errors are logged in a logfile of a
> wrong virtual host ...

Which one specifically?  Perhaps you made an error while redacting the config.

> is it problematic, if some virtual hosts have different IPv6 addresses but
> the same IPv4 address?

Not in this configuration.  Your vhosts only point to a single IP4
local address.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org