S
S
Stanislav Tamat2014-11-26 14:25:39
Apache HTTP Server
Stanislav Tamat, 2014-11-26 14:25:39

How to separate logs for subdomains (VirtualDocumentRoot) and prevent server response when requesting non-existing subdomains in Apache 2?

<VirtualHost *:80>

        UseCanonicalName Off
        ServerName  mydomain.com
        ServerAlias *.mydomain.com
        VirtualDocumentRoot /var/www/mydomain.com/htdocs/%-3+

        <Directory />
                Options FollowSymLinks
                AllowOverride All
        </Directory>

        DirectoryIndex index.html index.php index.htm index.shtml

        <Directory "/var/www/mydomain.com/htdocs">
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride All
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog /var/www/mydomain.com/logs/error_log
        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn
        CustomLog /var/www/mydomain.com/logs/access_log combined

There is a need to collect all logged information for subdomains in separate files. Regular expressions (%-3+) don't work in the ErrorLog parameter for some reason.
And another question for filling, how to make the server not respond to requests to non-existent subdomains (that is, if the directory /var/www/mydomain.com/htdocs/request-subdomain does not exist). At the moment, when requesting such a subdomain, it returns 404, of course, the *.mydomain.com A-record is registered in the DNS settings. Apache took these settings at one time from Hostland shared hosting, but there the connection to a non-existing subdomain was interrupted.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
ShamblerR, 2015-02-25
@ShamblerR

1. create several virtual hosts, each for its own subdomain
2. delete *.mydomain.com - this is still heresy
3. register in each virtual host its own root document and its own files.
4. Eror log does not support variables. if it is not possible for each subdomain to create a virtual host, then.
Parse the Apache log file so that the tools are wagon and distribute it after creation.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question