From e8c38550c9749ea5fab49db4412c585db02d07a8 Mon Sep 17 00:00:00 2001 From: cytopia Date: Wed, 19 Dec 2018 14:16:04 +0100 Subject: [PATCH] Extend Devilbox web ui with vhost configs --- .devilbox/www/htdocs/info_vhostgen.php | 66 +++++++++++++++++++ .devilbox/www/htdocs/vhosts.php | 9 ++- .devilbox/www/include/lib/container/Httpd.php | 29 ++++++++ docker-compose.yml | 2 +- 4 files changed, 104 insertions(+), 2 deletions(-) create mode 100644 .devilbox/www/htdocs/info_vhostgen.php diff --git a/.devilbox/www/htdocs/info_vhostgen.php b/.devilbox/www/htdocs/info_vhostgen.php new file mode 100644 index 00000000..f4b4fb87 --- /dev/null +++ b/.devilbox/www/htdocs/info_vhostgen.php @@ -0,0 +1,66 @@ + +authPage(); ?> +redirect('/vhosts.php'); +} +if (!strlen($_GET['name'])) { + loadClass('Helper')->redirect('/vhosts.php'); +} +$vhost = $_GET['name']; +$found = false; +$vhosts = loadClass('Httpd')->getVirtualHosts(); +foreach ($vhosts as $v) { + if ($vhost == $v['name']) { + $found = true; + break; + } +} +// Be safe before using outputs +$vhost = htmlentities($vhost); + +?> + + + + getHead(true); ?> + + + + getNavbar(); ?> + +
+ +

vhost-gen:

+
+
+ +
+
+ +

The Virtual Host "" does not exist.

+ + getVhostgenTemplatePath($vhost); ?> + +

No custom vhost-gen configuration found for "".

+ +

Note: If the resulting virtual host config does not reflect the vhost-gen template changes, you will need to restart the Devilbox.

+ Overview
+

virtual host config


+ + .conf + +

vhost-gen config


+

+ +
+ + +
+
+ +
+ + getFooter(); ?> + + diff --git a/.devilbox/www/htdocs/vhosts.php b/.devilbox/www/htdocs/vhosts.php index 937d5a75..629ba180 100644 --- a/.devilbox/www/htdocs/vhosts.php +++ b/.devilbox/www/htdocs/vhosts.php @@ -3,7 +3,7 @@ - getHead(); ?> + getHead(true); ?> @@ -24,6 +24,7 @@ Project DocumentRoot + Config Valid URL @@ -40,6 +41,12 @@ getEnv('HOST_PATH_HTTPD_DATADIR');?>//getEnv('HTTPD_DOCROOT_DIR');?> + + + getVhostgenTemplatePath($vHost['name'])) !== false): ?> + + +     diff --git a/.devilbox/www/include/lib/container/Httpd.php b/.devilbox/www/include/lib/container/Httpd.php index d101fe01..4e9db5df 100644 --- a/.devilbox/www/include/lib/container/Httpd.php +++ b/.devilbox/www/include/lib/container/Httpd.php @@ -165,6 +165,35 @@ class Httpd extends BaseClass implements BaseInterface return $version; } + public function getVhostgenTemplateName() + { + $httpd = strtolower($this->getName()); + if ($httpd == 'nginx') { + return 'nginx.yml'; + } + $version = $this->getVersion(); + + if (preg_match('/^2\.2.*/', $version)) { + return 'apache22.yml'; + } elseif (preg_match('/^2\.4.*/', $version)) { + return 'apache24.yml'; + } else { + return false; + } + } + + public function getVhostgenTemplatePath($vhost) + { + if (!($name = $this->getVhostgenTemplateName())) { + return false; + } + $dir = loadClass('Helper')->getEnv('HTTPD_TEMPLATE_DIR'); + + if (is_file('/shared/httpd/'.$vhost.'/'.$dir.'/'.$name)) { + return '/shared/httpd/'.$vhost.'/'.$dir.'/'.$name; + } + return false; + } /********************************************************************************* diff --git a/docker-compose.yml b/docker-compose.yml index 9ef6a9e3..c99d4b95 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -206,7 +206,7 @@ services: # Web Server # ------------------------------------------------------------ httpd: - image: devilbox/${HTTPD_SERVER:-nginx-stable}:0.23 + image: devilbox/${HTTPD_SERVER:-nginx-stable}:0.24 environment: