# Uses env vars:
# HTTPSERVER
# TESTS_ROOT_DIR

<IfModule http2_module>
  LogLevel http2:info
</IfModule>

<VirtualHost *:80>

  <IfModule http2_module>
    # Enable http2
    Protocols h2c http/1.1
  </IfModule>

  DocumentRoot ${TESTS_ROOT_DIR}

  #ErrorLog "${TESTS_ROOT_DIR}/apache_error.log"
  #CustomLog "${TESTS_ROOT_DIR}/apache_access.log" combined

  # Env vars used by the test code, which we get from the environment
  SetEnv HTTPSERVER ${HTTPSERVER}

  <Directory "${TESTS_ROOT_DIR}">
    Options FollowSymLinks MultiViews
    AllowOverride All

    Require all granted

    # needed for basic auth (PHP_AUTH_USER and PHP_AUTH_PW)
    RewriteEngine on
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization}]
  </Directory>

</VirtualHost>

<IfModule mod_ssl.c>

<VirtualHost _default_:443>

  <IfModule http2_module>
    # Enable http2
    Protocols h2 http/1.1
  </IfModule>

  DocumentRoot ${TESTS_ROOT_DIR}

  #ErrorLog "${TESTS_ROOT_DIR}/apache_error.log"
  #CustomLog "${TESTS_ROOT_DIR}/apache_access.log" combined

  # Env vars used by the test code, which we get from the environment
  SetEnv HTTPSERVER ${HTTPSERVER}

  <Directory "${TESTS_ROOT_DIR}">
    Options FollowSymLinks MultiViews
    AllowOverride All

    Require all granted

    # needed for basic auth (PHP_AUTH_USER and PHP_AUTH_PW)
    RewriteEngine on
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization}]
  </Directory>

  SSLEngine on
  # This cert is bundled by default in Ubuntu
  SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
  SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key

  <FilesMatch "\.(cgi|shtml|phtml|php)$">
    SSLOptions +StdEnvVars
  </FilesMatch>

  BrowserMatch "MSIE [2-6]" \
  nokeepalive ssl-unclean-shutdown \
  downgrade-1.0 force-response-1.0
  BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown

</VirtualHost>

</IfModule>
