Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🎅🎄🎁 #942

Merged
merged 27 commits into from
Dec 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
a35216f
Add Docker Compose Override File for Multi PHP versions
cytopia Dec 23, 2022
f2c0372
Update DNS server to latest version
cytopia Dec 23, 2022
d354d84
Update intranet and docker-compose
cytopia Dec 23, 2022
ee59885
Update CHANGELOG
cytopia Dec 23, 2022
2b4bf59
Add missing mariadb config directories
cytopia Dec 23, 2022
e3b7c2d
Adjust check-config.sh
cytopia Dec 23, 2022
6fa03e6
Fix env var names in docs
cytopia Dec 23, 2022
6b80453
Docs announce
cytopia Dec 23, 2022
e51f34c
Fix wrong link in docs
cytopia Dec 23, 2022
794bf0c
Atom no longer available
cytopia Dec 23, 2022
32c7bed
Fix magento install guide links
cytopia Dec 23, 2022
3b1c0b2
docs: fix bind links
cytopia Dec 23, 2022
0964c7b
Fix hostnames in CHANGELOG
cytopia Dec 24, 2022
0e3b963
Do not rely on external supervisord.conf for C&C web interface
cytopia Dec 24, 2022
55f0447
Add some colored output for logs in C&C
cytopia Dec 25, 2022
c64c455
Remove obsolete mounts from docker-compose
cytopia Dec 25, 2022
d5858da
Fix indentation
cytopia Dec 25, 2022
e60aa4e
Remove obsolete points from README
cytopia Dec 25, 2022
a560926
Removed obsolete supervisorctl config section
cytopia Dec 25, 2022
98f05d7
Updated UPDATING.md
cytopia Dec 25, 2022
dfda00d
Pinned HTTPD images
cytopia Dec 25, 2022
8b0788b
Add PHP version number to README files in cfg/ dir
cytopia Dec 25, 2022
200f6ce
Fix volume paths in php-multi compose files
cytopia Dec 25, 2022
ffba5d6
Remove obsolete mod/ directory
cytopia Dec 25, 2022
10571f7
Intranet: Show backend type on vhost page
cytopia Dec 25, 2022
025b45c
Fix IPv6 handling
cytopia Dec 25, 2022
3ffb360
Update check-config.sh
cytopia Dec 25, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .devilbox/www/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
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-24';
$DEVILBOX_API_PAGE = 'devilbox-api/status.json';

//
Expand Down
179 changes: 179 additions & 0 deletions .devilbox/www/htdocs/cnc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
<?php require '../config.php'; ?>
<?php loadClass('Helper')->authPage(); ?>
<?php
// TODO: This is currently a temporary hack to talk to supervisor on the HTTPD server
function run_supervisor_command($command) {
$supervisor_config_file = '/tmp/supervisorctl.conf';
$port = getenv('SVCTL_LISTEN_PORT');
$user = getenv('SVCTL_USER');
$pass = getenv('SVCTL_PASS');

$content = "[supervisorctl]\n";
$content .= "serverurl=http://httpd:" . $port . "\n";
$content .= "username=" . $user . "\n";
$content .= "password=" . $pass . "\n";

$fp = fopen($supervisor_config_file, 'w');
fwrite($fp, $content);
fclose($fp);

return loadClass('Helper')->exec('supervisorctl -c ' . $supervisor_config_file . ' ' . $command);
}


?>
<?php if ( isset($_POST['watcherd']) && $_POST['watcherd'] == 'reload' ) {
run_supervisor_command('restart watcherd');
sleep(1);
loadClass('Helper')->redirect('/cnc.php');
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<?php echo loadClass('Html')->getHead(true); ?>
</head>

<body>
<?php echo loadClass('Html')->getNavbar(); ?>

<div class="container">
<h1>Command & Control</h1>
<br/>
<br/>

<div class="row">
<div class="col-md-12">

<?php
$status_w = run_supervisor_command('status watcherd');
$status_h = run_supervisor_command('status httpd');

$words = preg_split("/\s+/", $status_w);
$data_w = array(
'name' => isset($words[0]) ? $words[0] : '',
'state' => isset($words[1]) ? $words[1] : '',
'pid' => isset($words[3]) ? preg_replace('/,$/', '', $words[3]) : '',
'uptime' => isset($words[5]) ? $words[5] : '',
);
$words = preg_split("/\s+/", $status_h);
$data_h = array(
'name' => isset($words[0]) ? $words[0] : '',
'state' => isset($words[1]) ? $words[1] : '',
'pid' => isset($words[3]) ? preg_replace('/,$/', '', $words[3]) : '',
'uptime' => isset($words[5]) ? $words[5] : '',
);
?>
<h3>Daemon overview</h3><br/>
<p>If you made a change to any vhost settings, you can trigger a manual reload here.</p>
<table class="table table-striped">
<thead class="thead-inverse">
<tr>
<th>Daemon</th>
<th>Status</th>
<th>Pid</th>
<th>Uptime</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<tr>
<td><?php echo $data_w['name']; ?></td>
<td><?php echo $data_w['state']; ?></td>
<td><?php echo $data_w['pid']; ?></td>
<td><?php echo $data_w['uptime']; ?></td>
<td><form method="post"><button type="submit" name="watcherd" value="reload" class="btn btn-primary">Reload</button></form></td>
</tr>
<tr>
<td><?php echo $data_h['name']; ?></td>
<td><?php echo $data_h['state']; ?></td>
<td><?php echo $data_h['pid']; ?></td>
<td><?php echo $data_h['uptime']; ?></td>
<td></td>
</tr>
</tbody>
</table>
<br/>
<br/>

<h3>watcherd stderr</h3>
<br/>
<?php
$output = run_supervisor_command('tail -1000000 watcherd stderr');
echo '<pre>';
foreach(preg_split("/((\r?\n)|(\r\n?))/", $output) as $line) {
if ( strpos($line, "[ERR]") !== false ) {
echo '<span style="color: #ff0000">' . $line . '</span>';
} else if ( strpos($line, "[emerg]") !== false ) {
echo '<span style="color: #ff0000">' . $line . '</span>';
} else if ( strpos($line, "Syntax error") !== false ) {
echo '<span style="color: #ff0000">' . $line . '</span>';
} else if ( strpos($line, "[WARN]") !== false ) {
echo '<span style="color: #ccaa00">' . $line . '</span>';
} else {
echo $line;
}
echo "\n";
}
echo '</pre>';
?>
<h3>watcherd stdout</h3>
<br/>
<?php
$output = run_supervisor_command('tail -1000000 watcherd');
echo '<pre>';
foreach(preg_split("/((\r?\n)|(\r\n?))/", $output) as $line) {
$pos_info = strpos($line, "[INFO]");
$pos_ok = strpos($line, "[OK]");
if ( $pos_ok !== false ) {
echo '<span style="color: #669a00"><strong>' . $line . '</strong></span>';
} else if ( $pos_info !== false && $pos_info == 0 ) {
echo '<span style="color: #0088cd">' . $line . '</span>';
} else {
echo $line;
}
echo "\n";
}
echo '</pre>';
?>

</div>
</div>

</div><!-- /.container -->

<?php echo loadClass('Html')->getFooter(); ?>
<script>
$(function() {
$('.subject').click(function() {
const id = ($(this).attr('id'));
const row = $('#mail-'+id);
row.toggle();

const bodyElement = row.find('.email-body')[0];
if(bodyElement.shadowRoot !== null){
// We've already fetched the message content.
return;
}

bodyElement.attachShadow({ mode: 'open' });
bodyElement.shadowRoot.innerHTML = 'Loading...';

$.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();
}
else{
bodyElement.shadowRoot.innerHTML = body;
}
})
})
// Handler for .ready() called.
});
</script>
</body>
</html>
2 changes: 1 addition & 1 deletion .devilbox/www/htdocs/mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@
$.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();
Expand Down
4 changes: 3 additions & 1 deletion .devilbox/www/htdocs/vhosts.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@
<tr>
<th>Project</th>
<th>DocumentRoot</th>
<th>Backend</th>
<th>Config</th>
<th>Valid</th>
<th>URL</th>
</tr>
</thead>
<tbody>
<?php
$totals = 70;
$totals = 0;
$filler = '&nbsp;';
for ($i=0; $i<$totals; $i++) {
$filler = $filler. '&nbsp;';
Expand All @@ -41,6 +42,7 @@
<tr>
<td><?php echo $vHost['name'];?></td>
<td><?php echo loadClass('Helper')->getEnv('HOST_PATH_HTTPD_DATADIR');?>/<?php echo $vHost['name'];?>/<?php echo loadClass('Helper')->getEnv('HTTPD_DOCROOT_DIR');?></td>
<td><?php echo loadClass('Httpd')->getVhostBackend($vHost['name']); ?></td>
<td>
<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>
<?php if (($vhostGen = loadClass('Httpd')->getVhostgenTemplatePath($vHost['name'])) !== false): ?>
Expand Down
4 changes: 4 additions & 0 deletions .devilbox/www/include/lib/Html.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ class Html
'name' => 'Virtual Hosts',
'path' => '/vhosts.php'
),
array(
'name' => 'C&C',
'path' => '/cnc.php'
),
array(
'name' => 'Emails',
'path' => '/mail.php'
Expand Down
27 changes: 27 additions & 0 deletions .devilbox/www/include/lib/container/Httpd.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,33 @@ public function getVhostgenTemplatePath($vhost)
return false;
}

public function getVhostBackend($vhost)
{
$dir = loadClass('Helper')->getEnv('HTTPD_TEMPLATE_DIR');
$name = 'backend.cfg';
$file = '/shared/httpd/'.$vhost.'/'.$dir.'/'.$name;
if (!file_exists($file)) {
return 'default';
}

$fp = fopen($file, 'r');
$cont = stream_get_contents($fp);
fclose($fp);

// conf:<type>:<proto>:<server>:<port>
$arr = explode(':', $cont);

$type = $arr[1];
$prot = $arr[2];
$addr = ''; // this may contain ':' itself due to IPv6 addresses
for ($i=3; $i<(count($arr)-1); $i++) {
$addr .= $arr[$i];
}
$port = $arr[count($arr) - 1];

return $prot.'://'.$addr.':'.$port;
}


/*********************************************************************************
*
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/zzz-reuse-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
cd "${GITHUB_WORKSPACE}/.tests/"

# Test full customization
make configure KEY=DEBUG_COMPOSE_ENTRYPOINT VAL="$(( RANDOM % 3 ))"
make configure KEY=DEBUG_ENTRYPOINT VAL="$(( RANDOM % 3 ))"
make configure KEY=DOCKER_LOGS VAL="$(( RANDOM % 1 ))"
make configure KEY=TLD_SUFFIX VAL=loc2
make configure KEY=TIMEZONE VAL='Europe/Berlin'
Expand Down
2 changes: 1 addition & 1 deletion .tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pull: ../.env
###
start: ../.env
@$(MAKE) --no-print-directory configure KEY=HOST_PATH_HTTPD_DATADIR VAL=.tests/www
@$(MAKE) --no-print-directory configure KEY=DEBUG_COMPOSE_ENTRYPOINT VAL=2
@$(MAKE) --no-print-directory configure KEY=DEBUG_ENTRYPOINT VAL=3
@$(MAKE) --no-print-directory configure KEY=NEW_UID VAL=$$(id -u)
@$(MAKE) --no-print-directory configure KEY=NEW_GID VAL=$$(id -g)
@$(PWD)/scripts/compose-start.sh
Expand Down
71 changes: 71 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,77 @@ Make sure to have a look at [UPDATING.md](https://github.com/cytopia/devilbox/bl
## Unreleased


## Release v3.0.0-beta-0.1 (2022-12-24) 🎅🎄🎁

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:

* https://github.com/devilbox/docker-nginx-stable/pull/55
* https://github.com/devilbox/docker-nginx-mainline/pull/57
* https://github.com/devilbox/docker-apache-2.2/pull/53
* https://github.com/devilbox/docker-apache-2.4/pull/54

Once it has been tested by the community, and potential errors have been addressed, a new major version will be released.

**IMPORTANT:** This release required you to copy `env-example` over onto `.env` due to some changes in variables.

### TL;DR

1. **Multiple PHP Versions**<br/>
Here is an example to run one project with a specific PHP version<br/>
```bash
# Enable all PHP versions
cp compose/docker-compose.override.yml-php-multi.yml docker-compose.override.yml
# Start default set and php80
docker-compose up php httpd bind php80
```
file: `/shared/httpd/<project>/.devilbox/backend.cfg`
```
conf:phpfpm:tcp:php80:9000
```
2. **Automated Reverse Proxy setup**<br/>
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/>
file: `/shared/httpd/<project>/.devilbox/backend.cfg`
```
conf:rproxy:http:127.0.0.1:3000
```
#### PHP hostnames and IP addresses

| PHP Version | Hostname | IP address |
|-------------|----------|----------------|
| 5.4 | php54 | 172.16.238.201 |
| 5.5 | php55 | 172.16.238.202 |
| 5.6 | php56 | 172.16.238.203 |
| 7.0 | php70 | 172.16.238.204 |
| 7.1 | php71 | 172.16.238.205 |
| 7.2 | php72 | 172.16.238.206 |
| 7.3 | php73 | 172.16.238.207 |
| 7.4 | php74 | 172.16.238.208 |
| 8.0 | php80 | 172.16.238.209 |
| 8.1 | php81 | 172.16.238.210 |
| 8.2 | php82 | 172.16.238.211 |

### Fixed
- 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)
- Fixed missing module `mod_proxy_html` in Apache 2.4 as per requirement from `vhost-gen` for Reverse Proxy setup
- Fixed encoding issue with Apache 2.4 Reverse Proxy by enabling `mod_xml2enc` module (Required by `mod_proxy_html`)
- Allow to run different PHP versions per project. fixes [#146](https://github.com/cytopia/devilbox/issues/146)

### Added
- New HTTPD server capable of auto reverse proxy creation (and different PHP versions per project)
- Intranet: Added Command & Control center to view watcherd logs and retrigger config in case of vhost changes
- Intranet: vhost page now also shows the configured Backend
- Environment variable `DEVILBOX_HTTPD_MGMT_PASS`
- Environment variable `DEVILBOX_HTTPD_MGMT_USER`
- New Docker Compose Override file `docker-compose.override.yml-php-multi.yml` (allows to run multiple PHP versions).
- Update Bind to latest version

### Changed
- Disabled `psr` extension by default [php-psr #78](https://github.com/jbboehr/php-psr/issues/78#issuecomment-722290110)
- Disabled `phalcon` extension by default
- Environment variable `DEBUG_COMPOSE_ENTRYPOINT` renamed to `DEBUG_ENTRYPOINT`
- Environment variable `HTTPD_TIMEOUT_TO_PHP_FPM` renamed to `HTTPD_BACKEND_TIMEOUT`


## Release v2.4.0 (2022-12-18)

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.
Expand Down
Loading