From d354d8416562024819e189c939f772fbae410daa Mon Sep 17 00:00:00 2001 From: cytopia Date: Fri, 23 Dec 2022 19:37:50 +0100 Subject: [PATCH] Update intranet and docker-compose --- .devilbox/www/config.php | 4 +- .devilbox/www/htdocs/cnc.php | 129 +++++++++++++++++++++++++++++ .devilbox/www/htdocs/mail.php | 2 +- .devilbox/www/htdocs/vhosts.php | 2 +- .devilbox/www/include/lib/Html.php | 4 + docker-compose.yml | 52 +++++++----- env-example | 31 ++++--- 7 files changed, 191 insertions(+), 33 deletions(-) create mode 100644 .devilbox/www/htdocs/cnc.php diff --git a/.devilbox/www/config.php b/.devilbox/www/config.php index 38f67ebb..5e076835 100644 --- a/.devilbox/www/config.php +++ b/.devilbox/www/config.php @@ -13,8 +13,8 @@ error_reporting(-1); putenv('RES_OPTIONS=retrans:1 retry:1 timeout:1 attempts:1'); -$DEVILBOX_VERSION = 'v2.4.0'; -$DEVILBOX_DATE = '2022-12-18'; +$DEVILBOX_VERSION = 'v3.0.0-beta-0.1'; +$DEVILBOX_DATE = '2022-12-23'; $DEVILBOX_API_PAGE = 'devilbox-api/status.json'; // diff --git a/.devilbox/www/htdocs/cnc.php b/.devilbox/www/htdocs/cnc.php new file mode 100644 index 00000000..1073721c --- /dev/null +++ b/.devilbox/www/htdocs/cnc.php @@ -0,0 +1,129 @@ + +authPage(); ?> +exec('supervisorctl -c /etc/supervisor/custom.d/supervisorctl.conf restart watcherd'); + sleep(1); + loadClass('Helper')->redirect('/cnc.php'); +} +?> + + + + getHead(true); ?> + + + + getNavbar(); ?> + +
+

Command & Control

+
+
+ +
+
+ + exec('supervisorctl -c /etc/supervisor/custom.d/supervisorctl.conf status watcherd'); + $status_h = loadClass('Helper')->exec('supervisorctl -c /etc/supervisor/custom.d/supervisorctl.conf status httpd'); + + $words = preg_split("/\s+/", $status_w); + $data_w = array( + 'name' => $words[0], + 'state' => $words[1], + 'pid' => preg_replace('/,$/', '', $words[3]), + 'uptime' => $words[5], + ); + $words = preg_split("/\s+/", $status_h); + $data_h = array( + 'name' => $words[0], + 'state' => $words[1], + 'pid' => preg_replace('/,$/', '', $words[3]), + 'uptime' => $words[5], + ); + ?> +

Daemon overview


+

If you made a change to any vhost settings, you can trigger a manual reload here.

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
DaemonStatusPidUptimeAction
+
+
+ +

watcherd stderr

+
+ exec('supervisorctl -c /etc/supervisor/custom.d/supervisorctl.conf tail -1000000 watcherd stderr'); + echo '
' . $output . '
'; + ?> +

watcherd stdout

+
+ exec('supervisorctl -c /etc/supervisor/custom.d/supervisorctl.conf tail -1000000 watcherd'); + echo '
' . $output . '
'; + ?> + +
+
+ +
+ + getFooter(); ?> + + + diff --git a/.devilbox/www/htdocs/mail.php b/.devilbox/www/htdocs/mail.php index 21dc6990..50e73b32 100644 --- a/.devilbox/www/htdocs/mail.php +++ b/.devilbox/www/htdocs/mail.php @@ -250,7 +250,7 @@ $messages = $MyMbox->get($sortOrderArr); $.get('?get-body=' + id, function(response){ response = JSON.parse(response); row.find('.raw-email-body').html(response.raw); - + const body = response.body; if(body === null){ row.find('.alert').show(); diff --git a/.devilbox/www/htdocs/vhosts.php b/.devilbox/www/htdocs/vhosts.php index 89881992..9f643c5c 100644 --- a/.devilbox/www/htdocs/vhosts.php +++ b/.devilbox/www/htdocs/vhosts.php @@ -31,7 +31,7 @@ 'Virtual Hosts', 'path' => '/vhosts.php' ), + array( + 'name' => 'C&C', + 'path' => '/cnc.php' + ), array( 'name' => 'Emails', 'path' => '/mail.php' diff --git a/docker-compose.yml b/docker-compose.yml index b2a19414..63e31b44 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -46,7 +46,7 @@ services: ## ## Debug? ## - - DEBUG_ENTRYPOINT=${DEBUG_COMPOSE_ENTRYPOINT} + - DEBUG_ENTRYPOINT=${DEBUG_ENTRYPOINT:-2} ## ## Memory consumption @@ -112,11 +112,17 @@ services: - ./.env environment: + ## + ## Supervisord Management (to connect to HTTPD supvervisord) + ## + - SVCTL_LISTEN_PORT=9001 + - SVCTL_USER=${DEVILBOX_HTTPD_MGMT_USER:-supervisor} + - SVCTL_PASS=${DEVILBOX_HTTPD_MGMT_PASS:-mypassword} + ## ## Debug/Logging ## - - DEBUG_ENTRYPOINT=${DEBUG_COMPOSE_ENTRYPOINT} - - DEBUG_COMPOSE_ENTRYPOINT + - DEBUG_ENTRYPOINT=${DEBUG_ENTRYPOINT:-2} - DOCKER_LOGS ## @@ -225,16 +231,26 @@ services: # Web Server # ------------------------------------------------------------ httpd: - image: devilbox/${HTTPD_SERVER}:${HTTPD_FLAVOUR:-alpine}-0.48 + image: devilbox/${HTTPD_SERVER}:${HTTPD_FLAVOUR:-alpine}-release-0.49b hostname: httpd environment: + ## + ## Supervisord Management + ## + - SVCTL_ENABLE=1 + - SVCTL_LISTEN_ADDR=0.0.0.0 + - SVCTL_LISTEN_PORT=9001 + - SVCTL_REMOTE_LOGS_ENABLE=1 + - SVCTL_USER=${DEVILBOX_HTTPD_MGMT_USER:-supervisor} + - SVCTL_PASS=${DEVILBOX_HTTPD_MGMT_PASS:-mypassword} + ## ## Debug/Logging ## - - DEBUG_ENTRYPOINT=${DEBUG_COMPOSE_ENTRYPOINT} - - DEBUG_RUNTIME=${DEBUG_COMPOSE_ENTRYPOINT} + - DEBUG_ENTRYPOINT=${DEBUG_ENTRYPOINT:-2} + - DEBUG_RUNTIME=1 - DOCKER_LOGS ## @@ -268,25 +284,23 @@ services: - MAIN_VHOST_SSL_TYPE=${HTTPD_VHOST_SSL_TYPE:-both} - MAIN_VHOST_SSL_GEN=1 - MAIN_VHOST_SSL_CN=${DEVILBOX_UI_SSL_CN:-localhost} + - MAIN_VHOST_BACKEND=conf:phpfpm:tcp:172.16.238.10:9000 + - MAIN_VHOST_BACKEND_TIMEOUT=${HTTPD_BACKEND_TIMEOUT:-180} + - MAIN_VHOST_ALIASES_ALLOW=/devilbox-api/:/var/www/default/api, /vhost.d/:/etc/httpd ## ## Enable Mass Vhosts ## - MASS_VHOST_ENABLE=1 - - MASS_VHOST_TLD=.${TLD_SUFFIX} - - MASS_VHOST_DOCROOT=${HTTPD_DOCROOT_DIR} - - MASS_VHOST_TPL=${HTTPD_TEMPLATE_DIR} + - MASS_VHOST_TLD_SUFFIX=.${TLD_SUFFIX} + - MASS_VHOST_DOCROOT_DIR=${HTTPD_DOCROOT_DIR} + - MASS_VHOST_TEMPLATE_DIR=${HTTPD_TEMPLATE_DIR} - MASS_VHOST_SSL_TYPE=${HTTPD_VHOST_SSL_TYPE:-both} - MASS_VHOST_SSL_GEN=1 - - ## - ## PHP-FPM Remote Server - ## - - COMPAT=${PHP_SERVER} - - PHP_FPM_ENABLE=1 - - PHP_FPM_SERVER_ADDR=172.16.238.10 - - PHP_FPM_SERVER_PORT=9000 - - PHP_FPM_TIMEOUT=${HTTPD_TIMEOUT_TO_PHP_FPM:-180} + - MASS_VHOST_BACKEND=conf:phpfpm:tcp:172.16.238.10:9000 + - MASS_VHOST_BACKEND_REWRITE=file:backend.cfg + - MASS_VHOST_BACKEND_TIMEOUT=${HTTPD_BACKEND_TIMEOUT:-180} + - MASS_VHOST_ALIASES_ALLOW=/devilbox-api/:/var/www/default/api:http(s)?://(.*)$$ ports: # ---- Format: ---- @@ -315,7 +329,7 @@ services: - ${DEVILBOX_PATH}/cfg/vhost-gen:/etc/vhost-gen.d:rw${MOUNT_OPTIONS} # Mount logs - - ${DEVILBOX_PATH}/log/${HTTPD_SERVER}:/var/log/${HTTPD_SERVER}:rw${MOUNT_OPTIONS} + - ${DEVILBOX_PATH}/log/${HTTPD_SERVER}:/var/log/httpd:rw${MOUNT_OPTIONS} # Certificate Authority public key - ${DEVILBOX_PATH}/ca:/ca:rw${MOUNT_OPTIONS} diff --git a/env-example b/env-example index 5d4f18f6..d200159b 100644 --- a/env-example +++ b/env-example @@ -28,10 +28,12 @@ ### Show all executed commands in each ### docker image during docker-compose up? ### -### 0: Quiet -### 1: Verbose -### 2: More verbose -DEBUG_COMPOSE_ENTRYPOINT=2 +### 0: Errors +### 1: Errors, Warnings +### 2: Errors, Warnings, Infos (Recommended) +### 3: Errors, Warnings, Infos, Debug +### 4: Errors, Warnings, Infos, Debug, Trace +DEBUG_ENTRYPOINT=2 ### @@ -236,6 +238,12 @@ DEVILBOX_VENDOR_PHPMYADMIN_AUTOLOGIN=1 ### DEVILBOX_VENDOR_PHPPGADMIN_AUTOLOGIN=1 +### +### HTTPD Supvervisord management +### +DEVILBOX_HTTPD_MGMT_USER=supervisord +DEVILBOX_HTTPD_MGMT_PASS=mypassword + ################################################################################ @@ -515,7 +523,7 @@ PHP_MODULES_ENABLE= ### ### PHP_MODULES_DISABLE=xdebug,imagick,swoole ### -PHP_MODULES_DISABLE=oci8,PDO_OCI,pdo_sqlsrv,sqlsrv,rdkafka,swoole +PHP_MODULES_DISABLE=oci8,PDO_OCI,pdo_sqlsrv,sqlsrv,rdkafka,swoole,psr,phalcon ### @@ -609,13 +617,16 @@ HTTPD_TEMPLATE_DIR=.devilbox ### -### Webserver timeout (in seconds) to upstream PHP-FPM server +### Remote (Upstream) Backend Timeout ### -### This value should be greater than PHP's max_execution_time, -### otherwise the php script could still run and the webserver will -### simply drop the connection before getting an answer by PHP. +### This setting specifies the Timeout for a remote Backend server, +### such as PHP-FPM or a Reverse Proxy. ### -HTTPD_TIMEOUT_TO_PHP_FPM=180 +### As for PHP, keep in mind that this value should be greater than +### PHP's max_execution_time,otherwise the php script could still +### run and the webserver will simply drop the connection before getting an answer by PHP. +### +HTTPD_BACKEND_TIMEOUT=180 ###