It seems that once you use virtual hosting, you really need to define a
default virtual host by making something the first in the config file.
On a server without virtual hosts, I have:
VirtualHost configuration:
ServerRoot: "/etc/httpd"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/etc/httpd/logs/error_log"
Mutex authdigest-client: using_defaults
Mutex proxy: using_defaults
Mutex authn-socache: using_defaults
Mutex default: dir="/run/httpd/" mechanism=default
Mutex mpm-accept: using_defaults
Mutex authdigest-opaque: using_defaults
Mutex proxy-balancer-shm: using_defaults
Mutex rewrite-map: using_defaults
PidFile: "/run/httpd/httpd.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="apache" id=48
Group: name="apache" id=48
But the one with:
VirtualHost configuration:
*:443 is a NameVirtualHost
default server webmail.test.htt-consult.com
(/etc/httpd/conf.d/roundcubemail.conf:2)
port 443 namevhost webmail.test.htt-consult.com
(/etc/httpd/conf.d/roundcubemail.conf:2)
alias webmail
port 443 namevhost z9m9z.test.htt-consult.com
(/etc/httpd/conf.d/ssl.conf:56)
ServerRoot: "/etc/httpd"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/etc/httpd/logs/error_log"
Mutex proxy: using_defaults
Mutex authn-socache: using_defaults
Mutex ssl-cache: using_defaults
Mutex default: dir="/run/httpd/" mechanism=default
Mutex mpm-accept: using_defaults
Mutex authdigest-opaque: using_defaults
Mutex proxy-balancer-shm: using_defaults
Mutex rewrite-map: using_defaults
Mutex authdigest-client: using_defaults
Mutex ssl-stapling: using_defaults
PidFile: "/run/httpd/httpd.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="apache" id=48
Group: name="apache" id=48
So I have to work up a default virtual host to get access as I need it.
OK learned a little.
On 03/14/2017 11:16 PM, Robert Moskowitz wrote:
I am reading:
https://httpd.apache.org/docs/2.4/vhosts/examples.html
And the statement:
"The asterisks match all addresses, so the main server serves no
requests. Due to the fact that the virtual host with |ServerName
www.example.com| is first in the configuration file, it has the
highest priority and can be seen as the default or primary server.
That means that if a request is received that does not match one of
the specified |ServerName
<https://httpd.apache.org/docs/2.4/mod/core.html#servername>|
directives, it will be served by this first |<VirtualHost>
<https://httpd.apache.org/docs/2.4/mod/core.html#virtualhost>|."
I read this that if I have a conf file that does not have virtual host
directive, it basically fails?
If my first virtual host is:
<VirtualHost *:80>
# Alias /roundcubemail /usr/share/roundcubemail
# Alias /webmail /usr/share/roundcubemail
ServerName webmail.$your_domain_tld
ServerAlias webmail
RewriteEngine On
ReWriteCond %{HTTP_HOST} =webmail.$your_domain_tld [NC]
RewriteCond %{SERVER_PORT} !=443
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
ExpiresDefault "access plus 10 years"
AddOutputFilterByType DEFLATE text/html text/plain text/xml
php_admin_flag session.cookie_secure "1"
</VirtualHost>
any config that does not use virtualhost (that is just an Alias and
directory directive) first passes through this first virtual host.
And the way to 'fix' this is to have a dummy first virtual directive:
/etc/httpd/conf.d/00-init.conf
<VirtualHost*:80>ServerNamefoo.bar.com</VirtualHost>
?