Current File : //etc/apache2/keyhelp/keyhelp.conf
#
#  _  __          _   _     _      (R)
# | |/ /___ _   _| |_| |___| |___
# | | /  -_) |_/ |  _  | -_) | _ \
# |_|\_\___|\__, |_| |_|___|_|  _/
#           |___/            |_|
#
# Webserver configuration for apache 2.4-fcgid
#

# Log format
<IfModule mod_logio.c>
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" keyhelp_log
</IfModule>
<IfModule !mod_logio.c>
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" 0 0" keyhelp_log
</IfModule>

# KeyHelp / Tools
<VirtualHost *:443>
    ServerName server.kundensystem.cc
    ServerAlias localhost 144.76.155.5 2a01:4f8:200:2312::2
    ServerAdmin hosting@kundensystem.cc

    DocumentRoot /home/keyhelp/www/keyhelp
    Options -Indexes
    SuexecUserGroup "keyhelp" "keyhelp"

    # Logging
    LogLevel warn
    CustomLog "${APACHE_LOG_DIR}/keyhelp/access.log" combined
    ErrorLog "${APACHE_LOG_DIR}/keyhelp/error.log"

    # SSL/TLS
    SSLEngine On
    SSLCertificateFile /etc/ssl/keyhelp/keyhelp.pem
    SSLCertificateChainFile /etc/ssl/keyhelp/keyhelp-ca.crt

    # HSTS
    <IfModule mod_headers.c>
        Header set Strict-Transport-Security "max-age=31536000"
    </IfModule>

    # Aliases
    Alias /awstats-icons      "/usr/share/awstats/icon"
    Alias /webmail            "/home/keyhelp/www/webmail"
    Alias /webstats           "/home/keyhelp/www/keyhelp.webstats"
    # Aliases (DB administration)
    Alias /db-administration  "/home/keyhelp/www/db-administration"
    Alias /db                 "/home/keyhelp/www/db-administration"
    Alias /phpmyadmin         "/home/keyhelp/www/db-administration"
    Alias /pma                "/home/keyhelp/www/db-administration"

    # Autoconfig / Autodiscover
    AliasMatch (?i)^/autoconfig(.*)   /home/keyhelp/www/keyhelp/misc/emailconfig$1
    AliasMatch (?i)^/autodiscover(.*) /home/keyhelp/www/keyhelp/misc/emailconfig$1

    # PHP files
    <FilesMatch \.php$>
        <If "-f %{REQUEST_FILENAME}">
            SetHandler "proxy:unix:/run/php/keyhelp_keyhelp.socket|fcgi://keyhelp_keyhelp.socket"
        </If>
    </FilesMatch>

    # Set some proxy properties (the string "unique-domain-name-string" should match
    # the one set in the FilesMatch directive.
    <Proxy fcgi://keyhelp_keyhelp.socket>
        ProxySet connectiontimeout=5 timeout=120
    </Proxy>

    # KeyHelp
    <Directory "/home/keyhelp/www/keyhelp">
        <Files "license.txt">
            Require all denied
        </Files>
        Require all granted
        AllowOverride All
    </Directory>
    <Directory "/home/keyhelp/www/keyhelp/bin/">
        Require all denied
    </Directory>

    # Rspamd
    RewriteEngine on
    RewriteRule ^/rspamd/(.*) http://localhost:11334/$1 [P,L]
    ProxyPreserveHost On
    ProxyPass /rspamd http://localhost:11334/
    ProxyPassReverse /rspamd http://localhost:11334/

    # Statistics
    <Directory "/home/keyhelp/www/keyhelp.webstats">
        Require all denied
        Options FollowSymLinks
        AllowOverride AuthConfig
    </Directory>

    # DB administration
    <Directory "/home/keyhelp/www/db-administration">
        Require all granted
        AllowOverride All
    </Directory>

    # Webmail
    <Directory "/home/keyhelp/www/webmail">
        Require all granted
        AllowOverride All
    </Directory>

    # Mime types
    <IfModule mod_mime.c>
        # Fonts
        AddType font/woff2 woff2
    </IfModule>

    # Expire headers
    <IfModule mod_expires.c>
        ExpiresActive On
        ExpiresDefault                          "access plus 1 days"
        # Data
        ExpiresByType text/xml                  "access plus 0 seconds"
        ExpiresByType text/html                 "access plus 0 seconds"
        ExpiresByType text/plain                "access plus 0 seconds"
        ExpiresByType application/xml           "access plus 0 seconds"
        ExpiresByType application/json          "access plus 0 seconds"
        # Scripts
        ExpiresByType text/css                  "access plus 1 month"
        ExpiresByType text/javascript           "access plus 1 month"
        ExpiresByType application/javascript    "access plus 1 month"
        ExpiresByType application/x-javascript  "access plus 1 month"
        # Images / Icons
        ExpiresByType image/gif                 "access plus 1 month"
        ExpiresByType image/png                 "access plus 1 month"
        ExpiresByType image/jpg                 "access plus 1 month"
        ExpiresByType image/jpeg                "access plus 1 month"
        ExpiresByType image/svg+xml             "access plus 1 month"
        ExpiresByType image/vnd.microsoft.icon  "access plus 1 month"
        ExpiresByType image/ico                 "access plus 1 month"
        ExpiresByType image/x-icon              "access plus 1 month"
        # Fonts
        ExpiresByType font/truetype             "access plus 1 month"
        ExpiresByType font/opentype             "access plus 1 month"
        ExpiresByType application/x-font-ttf    "access plus 1 month"
        ExpiresByType application/x-font-woff   "access plus 1 month"
        ExpiresByType application/font-woff     "access plus 1 month"
        ExpiresByType font/woff2                "access plus 1 month"
        # Others
        ExpiresByType application/pdf           "access plus 1 month"
    </IfModule>
</VirtualHost>

# Redirect HTTP -> HTTPS
<VirtualHost *:80>
    ServerName server.kundensystem.cc
    ServerAlias localhost 144.76.155.5 2a01:4f8:200:2312::2
    Redirect / https://server.kundensystem.cc/
</VirtualHost>

# User vhosts
IncludeOptional keyhelp/vhosts/*.conf

# Webmail subdomain
Include keyhelp/webmail.conf

# Autoconfig subdomain
Include keyhelp/autoconfig.conf

# Subdomain catch-all
IncludeOptional keyhelp/subdomain_catch_all.conf

# Default page, if domain not available.
<VirtualHost *:443>
    ServerName server.kundensystem.cc
    ServerAlias *
    SSLEngine On
    SSLCertificateFile /etc/ssl/keyhelp/keyhelp.pem
    SSLCertificateChainFile /etc/ssl/keyhelp/keyhelp-ca.crt
    RedirectMatch 302 ^ https://server.kundensystem.cc/index.php?page=domain_not_found
</VirtualHost>

# Default page | Redirect HTTP -> HTTPS
<VirtualHost *:80>
    ServerName server.kundensystem.cc
    ServerAlias *
    RedirectMatch 302 ^ https://server.kundensystem.cc/index.php?page=domain_not_found
</VirtualHost>