diff --git a/src/Handler.php b/src/Handler.php index 48954ecd8bf52174041dcaebc96388d5ecaf7ee4..c4171ce0499ce02bac7a30b88afd072c6bb58a4c 100644 --- a/src/Handler.php +++ b/src/Handler.php @@ -79,7 +79,10 @@ class Handler extends BaseHandler { $twig = new \Twig_Environment($twig_loader); $options['webRoot'] = $webRoot . '/'; $orig_ignored = FALSE; - foreach ($this->getFiles($projectRoot, $webRoot, $settingsPath) as $template => $def) { + foreach ($this->getFiles($projectRoot, $webRoot, $settingsPath, $options) as $template => $def) { + if (isset($def['condition']) && !$def['condition']) { + continue; + } if (!$fs->exists($def['dest'])) { $fs->mkdir($def['dest']); } @@ -161,11 +164,13 @@ class Handler extends BaseHandler { * Name of the web's root directory. * @param string $settingsPath * Name of the settings directory. + * @param array $options + * Keyed array with all current options. * * @return array * List of files. */ - protected function getFiles($projectRoot, $webRoot, $settingsPath): array { + protected function getFiles($projectRoot, $webRoot, $settingsPath, $options): array { return [ 'settings.docker.php' => [ 'dest' => $projectRoot . '/' . $settingsPath, @@ -194,7 +199,11 @@ class Handler extends BaseHandler { 'dest' => $projectRoot . '/tests/backstop', 'add2yaml' => TRUE, 'add2git' => TRUE, - ] + ], + 'vhost.conf' => [ + 'dest' => $projectRoot . '/apache', + 'condition' => $options['webserver']['overwriteconfig'], + ], ]; } @@ -256,6 +265,7 @@ class Handler extends BaseHandler { ], 'webserver' => [ 'type' => 'apache', + 'overwriteconfig' => (bool) $env->receiveGlobal('WEBSERVER_CONFIG_OVERWRITE', 'Overwrite webserver config (0 or 1)', '0'), ], 'varnish' => [ 'enable' => 0, diff --git a/templates/docker-compose.yml.twig b/templates/docker-compose.yml.twig index 666dfa5563cc57994835eb9715d3abd9feec93be..9848332c6cff8e0ed191de6b6fbf8b07c4ee8d6b 100644 --- a/templates/docker-compose.yml.twig +++ b/templates/docker-compose.yml.twig @@ -71,6 +71,9 @@ services: {% elseif webserver.type == 'apache' %} APACHE_VHOST_PRESET: php APACHE_LOG_LEVEL: debug +{% if webserver.overwriteconfig %} + APACHE_INCLUDE_CONF: /var/www/html/apache/vhost.conf +{% endif %} {% endif %} {{ webserver.type|upper }}_BACKEND_HOST: php {{ webserver.type|upper }}_SERVER_ROOT: /var/www/html/{{ webRoot }} diff --git a/templates/vhost.conf b/templates/vhost.conf new file mode 100644 index 0000000000000000000000000000000000000000..07750ae83f2b3290b972c83e34191428596c8609 --- /dev/null +++ b/templates/vhost.conf @@ -0,0 +1,15 @@ +<VirtualHost *:80> + DocumentRoot "/var/www/html/{{ webRoot }}/" + ServerName default + Include conf/preset.conf + <Location /> + Require all granted + </Location> + SetEnv HTTPS on + SetEnvIf X-Forwarded-Proto https HTTPS=on + SetEnvIf Request_URI "^/\.healthz$" dontlog + RedirectMatch 204 .healthz + <IfModule mod_proxy_http.c> + SSLProxyEngine on + </IfModule> +</VirtualHost>