Skip to content

Commit 6819619

Browse files
authored
Merge pull request #942 from cytopia/release/v3.0.0-beta-0.1
🎅🎄🎁
2 parents 2828e83 + 3ffb360 commit 6819619

77 files changed

Lines changed: 670 additions & 142 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.devilbox/www/config.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
putenv('RES_OPTIONS=retrans:1 retry:1 timeout:1 attempts:1');
1414

1515

16-
$DEVILBOX_VERSION = 'v2.4.0';
17-
$DEVILBOX_DATE = '2022-12-18';
16+
$DEVILBOX_VERSION = 'v3.0.0-beta-0.1';
17+
$DEVILBOX_DATE = '2022-12-24';
1818
$DEVILBOX_API_PAGE = 'devilbox-api/status.json';
1919

2020
//

.devilbox/www/htdocs/cnc.php

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
<?php require '../config.php'; ?>
2+
<?php loadClass('Helper')->authPage(); ?>
3+
<?php
4+
// TODO: This is currently a temporary hack to talk to supervisor on the HTTPD server
5+
function run_supervisor_command($command) {
6+
$supervisor_config_file = '/tmp/supervisorctl.conf';
7+
$port = getenv('SVCTL_LISTEN_PORT');
8+
$user = getenv('SVCTL_USER');
9+
$pass = getenv('SVCTL_PASS');
10+
11+
$content = "[supervisorctl]\n";
12+
$content .= "serverurl=http://httpd:" . $port . "\n";
13+
$content .= "username=" . $user . "\n";
14+
$content .= "password=" . $pass . "\n";
15+
16+
$fp = fopen($supervisor_config_file, 'w');
17+
fwrite($fp, $content);
18+
fclose($fp);
19+
20+
return loadClass('Helper')->exec('supervisorctl -c ' . $supervisor_config_file . ' ' . $command);
21+
}
22+
23+
24+
?>
25+
<?php if ( isset($_POST['watcherd']) && $_POST['watcherd'] == 'reload' ) {
26+
run_supervisor_command('restart watcherd');
27+
sleep(1);
28+
loadClass('Helper')->redirect('/cnc.php');
29+
}
30+
?>
31+
<!DOCTYPE html>
32+
<html lang="en">
33+
<head>
34+
<?php echo loadClass('Html')->getHead(true); ?>
35+
</head>
36+
37+
<body>
38+
<?php echo loadClass('Html')->getNavbar(); ?>
39+
40+
<div class="container">
41+
<h1>Command & Control</h1>
42+
<br/>
43+
<br/>
44+
45+
<div class="row">
46+
<div class="col-md-12">
47+
48+
<?php
49+
$status_w = run_supervisor_command('status watcherd');
50+
$status_h = run_supervisor_command('status httpd');
51+
52+
$words = preg_split("/\s+/", $status_w);
53+
$data_w = array(
54+
'name' => isset($words[0]) ? $words[0] : '',
55+
'state' => isset($words[1]) ? $words[1] : '',
56+
'pid' => isset($words[3]) ? preg_replace('/,$/', '', $words[3]) : '',
57+
'uptime' => isset($words[5]) ? $words[5] : '',
58+
);
59+
$words = preg_split("/\s+/", $status_h);
60+
$data_h = array(
61+
'name' => isset($words[0]) ? $words[0] : '',
62+
'state' => isset($words[1]) ? $words[1] : '',
63+
'pid' => isset($words[3]) ? preg_replace('/,$/', '', $words[3]) : '',
64+
'uptime' => isset($words[5]) ? $words[5] : '',
65+
);
66+
?>
67+
<h3>Daemon overview</h3><br/>
68+
<p>If you made a change to any vhost settings, you can trigger a manual reload here.</p>
69+
<table class="table table-striped">
70+
<thead class="thead-inverse">
71+
<tr>
72+
<th>Daemon</th>
73+
<th>Status</th>
74+
<th>Pid</th>
75+
<th>Uptime</th>
76+
<th>Action</th>
77+
</tr>
78+
</thead>
79+
<tbody>
80+
<tr>
81+
<td><?php echo $data_w['name']; ?></td>
82+
<td><?php echo $data_w['state']; ?></td>
83+
<td><?php echo $data_w['pid']; ?></td>
84+
<td><?php echo $data_w['uptime']; ?></td>
85+
<td><form method="post"><button type="submit" name="watcherd" value="reload" class="btn btn-primary">Reload</button></form></td>
86+
</tr>
87+
<tr>
88+
<td><?php echo $data_h['name']; ?></td>
89+
<td><?php echo $data_h['state']; ?></td>
90+
<td><?php echo $data_h['pid']; ?></td>
91+
<td><?php echo $data_h['uptime']; ?></td>
92+
<td></td>
93+
</tr>
94+
</tbody>
95+
</table>
96+
<br/>
97+
<br/>
98+
99+
<h3>watcherd stderr</h3>
100+
<br/>
101+
<?php
102+
$output = run_supervisor_command('tail -1000000 watcherd stderr');
103+
echo '<pre>';
104+
foreach(preg_split("/((\r?\n)|(\r\n?))/", $output) as $line) {
105+
if ( strpos($line, "[ERR]") !== false ) {
106+
echo '<span style="color: #ff0000">' . $line . '</span>';
107+
} else if ( strpos($line, "[emerg]") !== false ) {
108+
echo '<span style="color: #ff0000">' . $line . '</span>';
109+
} else if ( strpos($line, "Syntax error") !== false ) {
110+
echo '<span style="color: #ff0000">' . $line . '</span>';
111+
} else if ( strpos($line, "[WARN]") !== false ) {
112+
echo '<span style="color: #ccaa00">' . $line . '</span>';
113+
} else {
114+
echo $line;
115+
}
116+
echo "\n";
117+
}
118+
echo '</pre>';
119+
?>
120+
<h3>watcherd stdout</h3>
121+
<br/>
122+
<?php
123+
$output = run_supervisor_command('tail -1000000 watcherd');
124+
echo '<pre>';
125+
foreach(preg_split("/((\r?\n)|(\r\n?))/", $output) as $line) {
126+
$pos_info = strpos($line, "[INFO]");
127+
$pos_ok = strpos($line, "[OK]");
128+
if ( $pos_ok !== false ) {
129+
echo '<span style="color: #669a00"><strong>' . $line . '</strong></span>';
130+
} else if ( $pos_info !== false && $pos_info == 0 ) {
131+
echo '<span style="color: #0088cd">' . $line . '</span>';
132+
} else {
133+
echo $line;
134+
}
135+
echo "\n";
136+
}
137+
echo '</pre>';
138+
?>
139+
140+
</div>
141+
</div>
142+
143+
</div><!-- /.container -->
144+
145+
<?php echo loadClass('Html')->getFooter(); ?>
146+
<script>
147+
$(function() {
148+
$('.subject').click(function() {
149+
const id = ($(this).attr('id'));
150+
const row = $('#mail-'+id);
151+
row.toggle();
152+
153+
const bodyElement = row.find('.email-body')[0];
154+
if(bodyElement.shadowRoot !== null){
155+
// We've already fetched the message content.
156+
return;
157+
}
158+
159+
bodyElement.attachShadow({ mode: 'open' });
160+
bodyElement.shadowRoot.innerHTML = 'Loading...';
161+
162+
$.get('?get-body=' + id, function(response){
163+
response = JSON.parse(response);
164+
row.find('.raw-email-body').html(response.raw);
165+
166+
const body = response.body;
167+
if(body === null){
168+
row.find('.alert').show();
169+
}
170+
else{
171+
bodyElement.shadowRoot.innerHTML = body;
172+
}
173+
})
174+
})
175+
// Handler for .ready() called.
176+
});
177+
</script>
178+
</body>
179+
</html>

.devilbox/www/htdocs/mail.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@
250250
$.get('?get-body=' + id, function(response){
251251
response = JSON.parse(response);
252252
row.find('.raw-email-body').html(response.raw);
253-
253+
254254
const body = response.body;
255255
if(body === null){
256256
row.find('.alert').show();

.devilbox/www/htdocs/vhosts.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,15 @@
2424
<tr>
2525
<th>Project</th>
2626
<th>DocumentRoot</th>
27+
<th>Backend</th>
2728
<th>Config</th>
2829
<th>Valid</th>
2930
<th>URL</th>
3031
</tr>
3132
</thead>
3233
<tbody>
3334
<?php
34-
$totals = 70;
35+
$totals = 0;
3536
$filler = '&nbsp;';
3637
for ($i=0; $i<$totals; $i++) {
3738
$filler = $filler. '&nbsp;';
@@ -41,6 +42,7 @@
4142
<tr>
4243
<td><?php echo $vHost['name'];?></td>
4344
<td><?php echo loadClass('Helper')->getEnv('HOST_PATH_HTTPD_DATADIR');?>/<?php echo $vHost['name'];?>/<?php echo loadClass('Helper')->getEnv('HTTPD_DOCROOT_DIR');?></td>
45+
<td><?php echo loadClass('Httpd')->getVhostBackend($vHost['name']); ?></td>
4446
<td>
4547
<a title="Virtual host: <?php echo $vHost['name'];?>.conf" target="_blank" href="/vhost.d/<?php echo $vHost['name'];?>.conf"><i class="fa fa-cog" aria-hidden="true"></i></a>
4648
<?php if (($vhostGen = loadClass('Httpd')->getVhostgenTemplatePath($vHost['name'])) !== false): ?>

.devilbox/www/include/lib/Html.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ class Html
1818
'name' => 'Virtual Hosts',
1919
'path' => '/vhosts.php'
2020
),
21+
array(
22+
'name' => 'C&C',
23+
'path' => '/cnc.php'
24+
),
2125
array(
2226
'name' => 'Emails',
2327
'path' => '/mail.php'

.devilbox/www/include/lib/container/Httpd.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,33 @@ public function getVhostgenTemplatePath($vhost)
196196
return false;
197197
}
198198

199+
public function getVhostBackend($vhost)
200+
{
201+
$dir = loadClass('Helper')->getEnv('HTTPD_TEMPLATE_DIR');
202+
$name = 'backend.cfg';
203+
$file = '/shared/httpd/'.$vhost.'/'.$dir.'/'.$name;
204+
if (!file_exists($file)) {
205+
return 'default';
206+
}
207+
208+
$fp = fopen($file, 'r');
209+
$cont = stream_get_contents($fp);
210+
fclose($fp);
211+
212+
// conf:<type>:<proto>:<server>:<port>
213+
$arr = explode(':', $cont);
214+
215+
$type = $arr[1];
216+
$prot = $arr[2];
217+
$addr = ''; // this may contain ':' itself due to IPv6 addresses
218+
for ($i=3; $i<(count($arr)-1); $i++) {
219+
$addr .= $arr[$i];
220+
}
221+
$port = $arr[count($arr) - 1];
222+
223+
return $prot.'://'.$addr.':'.$port;
224+
}
225+
199226

200227
/*********************************************************************************
201228
*

.github/workflows/zzz-reuse-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ jobs:
7676
cd "${GITHUB_WORKSPACE}/.tests/"
7777
7878
# Test full customization
79-
make configure KEY=DEBUG_COMPOSE_ENTRYPOINT VAL="$(( RANDOM % 3 ))"
79+
make configure KEY=DEBUG_ENTRYPOINT VAL="$(( RANDOM % 3 ))"
8080
make configure KEY=DOCKER_LOGS VAL="$(( RANDOM % 1 ))"
8181
make configure KEY=TLD_SUFFIX VAL=loc2
8282
make configure KEY=TIMEZONE VAL='Europe/Berlin'

.tests/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pull: ../.env
5151
###
5252
start: ../.env
5353
@$(MAKE) --no-print-directory configure KEY=HOST_PATH_HTTPD_DATADIR VAL=.tests/www
54-
@$(MAKE) --no-print-directory configure KEY=DEBUG_COMPOSE_ENTRYPOINT VAL=2
54+
@$(MAKE) --no-print-directory configure KEY=DEBUG_ENTRYPOINT VAL=3
5555
@$(MAKE) --no-print-directory configure KEY=NEW_UID VAL=$$(id -u)
5656
@$(MAKE) --no-print-directory configure KEY=NEW_GID VAL=$$(id -g)
5757
@$(PWD)/scripts/compose-start.sh

CHANGELOG.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,77 @@ Make sure to have a look at [UPDATING.md](https://github.com/cytopia/devilbox/bl
66
## Unreleased
77

88

9+
## Release v3.0.0-beta-0.1 (2022-12-24) 🎅🎄🎁
10+
11+
This is a beta release, using a completely rewritten set of HTTPD server, which allow easy reverse Proxy integration and different PHP versions per project:
12+
13+
* https://github.com/devilbox/docker-nginx-stable/pull/55
14+
* https://github.com/devilbox/docker-nginx-mainline/pull/57
15+
* https://github.com/devilbox/docker-apache-2.2/pull/53
16+
* https://github.com/devilbox/docker-apache-2.4/pull/54
17+
18+
Once it has been tested by the community, and potential errors have been addressed, a new major version will be released.
19+
20+
**IMPORTANT:** This release required you to copy `env-example` over onto `.env` due to some changes in variables.
21+
22+
### TL;DR
23+
24+
1. **Multiple PHP Versions**<br/>
25+
Here is an example to run one project with a specific PHP version<br/>
26+
```bash
27+
# Enable all PHP versions
28+
cp compose/docker-compose.override.yml-php-multi.yml docker-compose.override.yml
29+
# Start default set and php80
30+
docker-compose up php httpd bind php80
31+
```
32+
file: `/shared/httpd/<project>/.devilbox/backend.cfg`
33+
```
34+
conf:phpfpm:tcp:php80:9000
35+
```
36+
2. **Automated Reverse Proxy setup**<br/>
37+
Here is an example to proxy one project to a backend service (e.g. NodeJS or Python application, which runs in the PHP container on port 3000)<br/>
38+
file: `/shared/httpd/<project>/.devilbox/backend.cfg`
39+
```
40+
conf:rproxy:http:127.0.0.1:3000
41+
```
42+
#### PHP hostnames and IP addresses
43+
44+
| PHP Version | Hostname | IP address |
45+
|-------------|----------|----------------|
46+
| 5.4 | php54 | 172.16.238.201 |
47+
| 5.5 | php55 | 172.16.238.202 |
48+
| 5.6 | php56 | 172.16.238.203 |
49+
| 7.0 | php70 | 172.16.238.204 |
50+
| 7.1 | php71 | 172.16.238.205 |
51+
| 7.2 | php72 | 172.16.238.206 |
52+
| 7.3 | php73 | 172.16.238.207 |
53+
| 7.4 | php74 | 172.16.238.208 |
54+
| 8.0 | php80 | 172.16.238.209 |
55+
| 8.1 | php81 | 172.16.238.210 |
56+
| 8.2 | php82 | 172.16.238.211 |
57+
58+
### Fixed
59+
- Fixed Protocol substitution bug in Reverse Proxy generation for Apache 2.2 and Apache 2.4 [vhost-gen #49](https://github.com/devilbox/vhost-gen/pull/49) [vhost-gen #50](https://github.com/devilbox/vhost-gen/pull/50)
60+
- Fixed missing module `mod_proxy_html` in Apache 2.4 as per requirement from `vhost-gen` for Reverse Proxy setup
61+
- Fixed encoding issue with Apache 2.4 Reverse Proxy by enabling `mod_xml2enc` module (Required by `mod_proxy_html`)
62+
- Allow to run different PHP versions per project. fixes [#146](https://github.com/cytopia/devilbox/issues/146)
63+
64+
### Added
65+
- New HTTPD server capable of auto reverse proxy creation (and different PHP versions per project)
66+
- Intranet: Added Command & Control center to view watcherd logs and retrigger config in case of vhost changes
67+
- Intranet: vhost page now also shows the configured Backend
68+
- Environment variable `DEVILBOX_HTTPD_MGMT_PASS`
69+
- Environment variable `DEVILBOX_HTTPD_MGMT_USER`
70+
- New Docker Compose Override file `docker-compose.override.yml-php-multi.yml` (allows to run multiple PHP versions).
71+
- Update Bind to latest version
72+
73+
### Changed
74+
- Disabled `psr` extension by default [php-psr #78](https://github.com/jbboehr/php-psr/issues/78#issuecomment-722290110)
75+
- Disabled `phalcon` extension by default
76+
- Environment variable `DEBUG_COMPOSE_ENTRYPOINT` renamed to `DEBUG_ENTRYPOINT`
77+
- Environment variable `HTTPD_TIMEOUT_TO_PHP_FPM` renamed to `HTTPD_BACKEND_TIMEOUT`
78+
79+
980
## Release v2.4.0 (2022-12-18)
1081

1182
This release might be a bit bumpy due to a massive amount of changes in upstream projects. If you encounter issues, please do raise tickets.

0 commit comments

Comments
 (0)