LoadModule deflate_module /usr/local/apache2/modules/mod_deflate.so
LoadModule proxy_module /usr/local/apache2/modules/mod_proxy.so
LoadModule proxy_fcgi_module /usr/local/apache2/modules/mod_proxy_fcgi.so
LoadModule rewrite_module /usr/local/apache2/modules/mod_rewrite.so
LoadModule ssl_module /usr/local/apache2/modules/mod_ssl.so

<VirtualHost *:80>
    
    # ServerName {{prj_name}}.test
    ServerName localhost.loc

    # Define the vhost to serve files
    DocumentRoot "{{workdir_contao_public}}"

    <Directory "{{workdir_contao_public}}">
        DirectoryIndex index.php index.html index.htm
    
        AllowOverride All
        Options All
    
        RewriteEngine on
        RewriteBase /
    
        Order allow,deny
        Allow from all
        Require all granted
    </Directory>

    # PHP-FPM Definition
    #php = name of php service
    <FilesMatch \.php$>
        Require all granted
        SetHandler proxy:fcgi://php:9000
    </FilesMatch>
    
    <Proxy "fcgi://php:9000/">
        ProxySet timeout=180
        ProxySet connectiontimeout=180
    </Proxy>

    # If the php file doesn't exist, disable the proxy handler.
    # This will allow .htaccess rewrite rules to work and
    # the client will see the default 404 page of Apache
    RewriteCond %{REQUEST_FILENAME} \.php$
    RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI} !-f
    RewriteRule (.*) - [H=text/html]

</VirtualHost>

<VirtualHost *:{{ssl_port}}>
    
    # ServerName {{prj_name}}.test
    ServerName localhost.loc

    SSLEngine on
    SSLCertificateKeyFile /usr/local/apache2/ssl/localhost.loc.key
    SSLCertificateFile /usr/local/apache2/ssl/localhost.loc.cert
    # SSLCertificateKeyFile /usr/local/apache2/ssl/localhost.key
    # SSLCertificateFile /usr/local/apache2/ssl/localhost.cert
    SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown

    # Define the vhost to serve files
    DocumentRoot "{{workdir_contao_public}}"

    <Directory "{{workdir_contao_public}}">
        DirectoryIndex index.php index.html index.htm
    
        AllowOverride All
        Options All
    
        RewriteEngine on
        RewriteBase /
    
        Order allow,deny
        Allow from all
        Require all granted
    </Directory>

    # PHP-FPM Definition
    #php = name of php service
    <FilesMatch \.php$>
        Require all granted
        SetHandler proxy:fcgi://php:9000
    </FilesMatch>
    
    <Proxy "fcgi://php:9000/">
        ProxySet timeout=180
        ProxySet connectiontimeout=180
    </Proxy>

    # If the php file doesn't exist, disable the proxy handler.
    # This will allow .htaccess rewrite rules to work and
    # the client will see the default 404 page of Apache
    RewriteCond %{REQUEST_FILENAME} \.php$
    RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI} !-f
    RewriteRule (.*) - [H=text/html]

</VirtualHost>

<VirtualHost *:{{ssl_port}}>
    
    # ServerName {{prj_name}}.test
    ServerName www.localhost.loc

    SSLEngine on
    SSLCertificateKeyFile /usr/local/apache2/ssl/www.localhost.loc.key
    SSLCertificateFile /usr/local/apache2/ssl/www.localhost.loc.cert
    # SSLCertificateKeyFile /usr/local/apache2/ssl/localhost.key
    # SSLCertificateFile /usr/local/apache2/ssl/localhost.cert
    SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown

    # Define the vhost to serve files
    DocumentRoot "{{workdir_contao_public}}"

    <Directory "{{workdir_contao_public}}">
        DirectoryIndex index.php index.html index.htm
    
        AllowOverride All
        Options All
    
        RewriteEngine on
        RewriteBase /
    
        Order allow,deny
        Allow from all
        Require all granted
    </Directory>

    # PHP-FPM Definition
    #php = name of php service
    <FilesMatch \.php$>
        Require all granted
        SetHandler proxy:fcgi://php:9000
    </FilesMatch>
    
    <Proxy "fcgi://php:9000/">
        ProxySet timeout=180
        ProxySet connectiontimeout=180
    </Proxy>

    # If the php file doesn't exist, disable the proxy handler.
    # This will allow .htaccess rewrite rules to work and
    # the client will see the default 404 page of Apache
    RewriteCond %{REQUEST_FILENAME} \.php$
    RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI} !-f
    RewriteRule (.*) - [H=text/html]

</VirtualHost>
