mirror of
https://github.com/cytopia/devilbox.git
synced 2025-01-31 00:23:51 +00:00
parent
54e00598cd
commit
0afeefd964
@ -11,8 +11,8 @@ NameVirtualHost *:80
|
|||||||
|
|
||||||
ServerAdmin root@localhost
|
ServerAdmin root@localhost
|
||||||
|
|
||||||
ErrorLog /var/log/apache-2.2/localhost-error.log
|
ErrorLog /var/log/apache-2.2/devilbox-error.log
|
||||||
CustomLog /var/log/apache-2.2/localhost-access.log combined
|
CustomLog /var/log/apache-2.2/devilbox-access.log combined
|
||||||
|
|
||||||
DirectoryIndex index.php index.html
|
DirectoryIndex index.php index.html
|
||||||
|
|
||||||
|
@ -11,6 +11,10 @@
|
|||||||
ServerAlias *.*
|
ServerAlias *.*
|
||||||
ServerAdmin root@localhost
|
ServerAdmin root@localhost
|
||||||
|
|
||||||
|
# Required for DNS checking
|
||||||
|
SetEnvIf Origin "http(s)?://(domain1.org|localhost|127.0.0.1|httpd)$" AccessControlAllowOrigin=$0$1
|
||||||
|
Header add Access-Control-Allow-Origin %{AccessControlAllowOrigin}e env=AccessControlAllowOrigin
|
||||||
|
|
||||||
LogFormat "%V;%h;%l;%u;%t;\"%r\";%>s;%b;\"%{Referer}i\";\"%{User-agent}i\"" vcommon
|
LogFormat "%V;%h;%l;%u;%t;\"%r\";%>s;%b;\"%{Referer}i\";\"%{User-agent}i\"" vcommon
|
||||||
CustomLog "/var/log/apache-2.2/projects-access.log" vcommon
|
CustomLog "/var/log/apache-2.2/projects-access.log" vcommon
|
||||||
ErrorLog /var/log/apache-2.2/projects-error.log
|
ErrorLog /var/log/apache-2.2/projects-error.log
|
||||||
|
@ -11,8 +11,8 @@
|
|||||||
|
|
||||||
ServerAdmin root@localhost
|
ServerAdmin root@localhost
|
||||||
|
|
||||||
ErrorLog /var/log/apache-2.4/localhost-error.log
|
ErrorLog /var/log/apache-2.4/devilbox-error.log
|
||||||
CustomLog /var/log/apache-2.4/localhost-access.log combined
|
CustomLog /var/log/apache-2.4/devilbox-access.log combined
|
||||||
|
|
||||||
DirectoryIndex index.php index.html
|
DirectoryIndex index.php index.html
|
||||||
|
|
||||||
|
@ -11,6 +11,10 @@
|
|||||||
ServerAlias *.*
|
ServerAlias *.*
|
||||||
ServerAdmin root@localhost
|
ServerAdmin root@localhost
|
||||||
|
|
||||||
|
# Required for DNS checking
|
||||||
|
SetEnvIf Origin "http(s)?://(domain1.org|localhost|127.0.0.1|httpd)$" AccessControlAllowOrigin=$0$1
|
||||||
|
Header add Access-Control-Allow-Origin %{AccessControlAllowOrigin}e env=AccessControlAllowOrigin
|
||||||
|
|
||||||
LogFormat "%V;%h;%l;%u;%t;\"%r\";%>s;%b;\"%{Referer}i\";\"%{User-agent}i\"" vcommon
|
LogFormat "%V;%h;%l;%u;%t;\"%r\";%>s;%b;\"%{Referer}i\";\"%{User-agent}i\"" vcommon
|
||||||
CustomLog "/var/log/apache-2.4/projects-access.log" vcommon
|
CustomLog "/var/log/apache-2.4/projects-access.log" vcommon
|
||||||
ErrorLog /var/log/apache-2.4/projects-error.log
|
ErrorLog /var/log/apache-2.4/projects-error.log
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
access_log /var/log/nginx-mainline/access.log main;
|
|
||||||
error_log /var/log/nginx-mainline/error.log warn;
|
|
||||||
|
|
||||||
charset utf-8;
|
charset utf-8;
|
||||||
|
|
||||||
send_timeout 60;
|
send_timeout 60;
|
||||||
|
@ -6,17 +6,17 @@ server {
|
|||||||
listen 80 default_server;
|
listen 80 default_server;
|
||||||
server_name _;
|
server_name _;
|
||||||
server_name localhost;
|
server_name localhost;
|
||||||
server_name 127\.0\.0\.1;
|
server_name 127.0.0.1;
|
||||||
server_name httpd;
|
server_name httpd;
|
||||||
server_name 172\.16\.238\..*;
|
server_name 172.16.238.*;
|
||||||
|
|
||||||
|
|
||||||
# Root directive
|
# Root directive
|
||||||
root /var/www/default/htdocs;
|
root /var/www/default/htdocs;
|
||||||
index index.php;
|
index index.php;
|
||||||
|
|
||||||
access_log /var/log/nginx-mainline/localhost-access.log main;
|
access_log /var/log/nginx-mainline/devilbox-access.log main;
|
||||||
error_log /var/log/nginx-mainline/localhost-error.log warn;
|
error_log /var/log/nginx-mainline/devilbox-error.log warn;
|
||||||
|
|
||||||
|
|
||||||
# Front-controller pattern as recommended by the nginx docs
|
# Front-controller pattern as recommended by the nginx docs
|
||||||
|
@ -21,6 +21,12 @@ server {
|
|||||||
|
|
||||||
# PHP FPM
|
# PHP FPM
|
||||||
location ~ \.php?$ {
|
location ~ \.php?$ {
|
||||||
|
|
||||||
|
# Required for DNS checking
|
||||||
|
if ( $http_origin ~* (https?://(localhost|127\.0\.0\.1|httpd)$) ) {
|
||||||
|
add_header "Access-Control-Allow-Origin" "$http_origin";
|
||||||
|
}
|
||||||
|
|
||||||
# PHP.INI:
|
# PHP.INI:
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
# // Find this:
|
# // Find this:
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
access_log /var/log/nginx-stable/access.log main;
|
|
||||||
error_log /var/log/nginx-stable/error.log warn;
|
|
||||||
|
|
||||||
charset utf-8;
|
charset utf-8;
|
||||||
|
|
||||||
send_timeout 60;
|
send_timeout 60;
|
||||||
|
@ -6,16 +6,16 @@ server {
|
|||||||
listen 80 default_server;
|
listen 80 default_server;
|
||||||
server_name _;
|
server_name _;
|
||||||
server_name localhost;
|
server_name localhost;
|
||||||
server_name 127\.0\.0\.1;
|
server_name 127.0.0.1;
|
||||||
server_name httpd;
|
server_name httpd;
|
||||||
server_name 172\.16\.238\..*;
|
server_name 172.16.238.*;
|
||||||
|
|
||||||
# Root directive
|
# Root directive
|
||||||
root /var/www/default/htdocs;
|
root /var/www/default/htdocs;
|
||||||
index index.php;
|
index index.php;
|
||||||
|
|
||||||
access_log /var/log/nginx-stable/localhost-access.log main;
|
access_log /var/log/nginx-stable/devilbox-access.log main;
|
||||||
error_log /var/log/nginx-stable/localhost-error.log warn;
|
error_log /var/log/nginx-stable/devilbox-error.log warn;
|
||||||
|
|
||||||
|
|
||||||
# Front-controller pattern as recommended by the nginx docs
|
# Front-controller pattern as recommended by the nginx docs
|
||||||
|
@ -21,6 +21,12 @@ server {
|
|||||||
|
|
||||||
# PHP FPM
|
# PHP FPM
|
||||||
location ~ \.php?$ {
|
location ~ \.php?$ {
|
||||||
|
|
||||||
|
# Required for DNS checking
|
||||||
|
if ( $http_origin ~* (https?://(localhost|127\.0\.0\.1|httpd)$) ) {
|
||||||
|
add_header "Access-Control-Allow-Origin" "$http_origin";
|
||||||
|
}
|
||||||
|
|
||||||
# PHP.INI:
|
# PHP.INI:
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
# // Find this:
|
# // Find this:
|
||||||
|
@ -53,7 +53,7 @@ $connection['Httpd'][$host] = array(
|
|||||||
'host' => $host,
|
'host' => $host,
|
||||||
'succ' => $succ
|
'succ' => $succ
|
||||||
);
|
);
|
||||||
$host = 'random.loc';
|
$host = 'random.'.loadClass('Php')->getTldSuffix();
|
||||||
$succ = \devilbox\Httpd::testConnection($error, $host);
|
$succ = \devilbox\Httpd::testConnection($error, $host);
|
||||||
$connection['Httpd'][$host] = array(
|
$connection['Httpd'][$host] = array(
|
||||||
'error' => $error,
|
'error' => $error,
|
||||||
@ -406,7 +406,7 @@ function getCirle($name) {
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>vHost TLD</th>
|
<th>vHost TLD</th>
|
||||||
<td>*.loc</td>
|
<td>*.<?php echo loadClass('Php')->getTldSuffix(); ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>DNS</th>
|
<th>DNS</th>
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
<?php foreach ($vHosts as $vHost): ?>
|
<?php foreach ($vHosts as $vHost): ?>
|
||||||
<tr>
|
<tr>
|
||||||
<td><?php echo $vHost['name'];?></td>
|
<td><?php echo $vHost['name'];?></td>
|
||||||
<td><?php echo $Docker->getEnv('HOST_PATH_TO_WWW_DOCROOTS');?>/<?php echo $vHost['name'];?>/htdocs</td>
|
<td><?php echo $Docker->getEnv('HOST_PATH_HTTPD_DATADIR');?>/<?php echo $vHost['name'];?>/htdocs</td>
|
||||||
<td class="text-xs-center text-xs-small" id="valid-<?php echo $vHost['name'];?>"> </td>
|
<td class="text-xs-center text-xs-small" id="valid-<?php echo $vHost['name'];?>"> </td>
|
||||||
<td id="href-<?php echo $vHost['name'];?>"><?php echo $filler;?></td>
|
<td id="href-<?php echo $vHost['name'];?>"><?php echo $filler;?></td>
|
||||||
</tr>
|
</tr>
|
||||||
@ -49,8 +49,8 @@
|
|||||||
</table>
|
</table>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<h4>No projects here.</h4>
|
<h4>No projects here.</h4>
|
||||||
<p>Simply create a folder in <strong><?php echo $Docker->getEnv('HOST_PATH_TO_WWW_DOCROOTS');?></strong> (on your host computer - not inside the docker).</p>
|
<p>Simply create a folder in <strong><?php echo $Docker->getEnv('HOST_PATH_HTTPD_DATADIR');?></strong> (on your host computer - not inside the docker).</p>
|
||||||
<p><strong>Example:</strong><br/><?php echo $Docker->getEnv('HOST_PATH_TO_WWW_DOCROOTS');?>/my_project</p>
|
<p><strong>Example:</strong><br/><?php echo $Docker->getEnv('HOST_PATH_HTTPD_DATADIR');?>/my_project</p>
|
||||||
<?php endif;?>
|
<?php endif;?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -83,9 +83,7 @@
|
|||||||
el_valid.innerHTML = 'ERR';
|
el_valid.innerHTML = 'ERR';
|
||||||
el_href.innerHTML = error;
|
el_href.innerHTML = error;
|
||||||
} else {
|
} else {
|
||||||
el_valid.className += ' bg-success';
|
checkDns(vhost);
|
||||||
el_valid.innerHTML = 'OK';
|
|
||||||
el_href.innerHTML = '<a target="_blank" href="http://'+vhost+'.<?php echo $Docker->getTld().$Docker->getPort();?>">'+vhost+'.<?php echo $Docker->getTld().$Docker->getPort();?></a>';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -93,6 +91,46 @@
|
|||||||
xhttp.send();
|
xhttp.send();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if DNS record is set in /etc/hosts (or via attached DNS server)
|
||||||
|
* for TLD_SUFFIX
|
||||||
|
*/
|
||||||
|
function checkDns(vhost) {
|
||||||
|
var xhttp = new XMLHttpRequest();
|
||||||
|
// Timeout after 1 seconds and mark it invalid DNS
|
||||||
|
xhttp.timeout = <?php echo loadClass('Docker')->getEnv('DNS_CHECK_TIMEOUT');?>000;
|
||||||
|
|
||||||
|
var el_valid = document.getElementById('valid-' + vhost);
|
||||||
|
var el_href = document.getElementById('href-' + vhost);
|
||||||
|
var error = this.responseText;
|
||||||
|
|
||||||
|
xhttp.onreadystatechange = function(e) {
|
||||||
|
if (this.readyState == 4 && this.status == 200) {
|
||||||
|
//clearTimeout(xmlHttpTimeout);
|
||||||
|
el_valid.className += ' bg-success';
|
||||||
|
el_valid.innerHTML = 'OK';
|
||||||
|
el_href.innerHTML = '<a target="_blank" href="http://'+vhost+'.<?php echo loadClass('Php')->getTldSuffix().$Docker->getPort();?>">'+vhost+'.<?php echo loadClass('Php')->getTldSuffix().$Docker->getPort();?></a>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
xhttp.ontimeout = function(e) {
|
||||||
|
el_valid.className += ' bg-danger';
|
||||||
|
el_valid.innerHTML = 'ERR';
|
||||||
|
el_href.innerHTML = 'No DNS record found: <code>127.0.0.1 '+vhost+'.<?php echo loadClass('Php')->getTldSuffix();?></code>';
|
||||||
|
}
|
||||||
|
//xhttp.abort = function(e) {
|
||||||
|
// el_valid.className += ' bg-danger';
|
||||||
|
// el_valid.innerHTML = 'ERR';
|
||||||
|
// el_href.innerHTML = 'No DNS record found: <code>127.0.0.1 '+vhost+'.<?php echo loadClass('Php')->getTldSuffix();?></code>';
|
||||||
|
//}
|
||||||
|
xhttp.open('GET', 'http://'+vhost+'.<?php echo loadClass('Php')->getTldSuffix();?>', true);
|
||||||
|
xhttp.send();
|
||||||
|
// Timeout to abort in 1 second
|
||||||
|
//var xmlHttpTimeout=setTimeout(ajaxTimeout,20000);
|
||||||
|
//function ajaxTimeout(){
|
||||||
|
// xhttp.abort();
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
var vhosts = document.getElementsByName('vhost[]');
|
var vhosts = document.getElementsByName('vhost[]');
|
||||||
|
|
||||||
|
@ -47,13 +47,6 @@ class Docker
|
|||||||
*/
|
*/
|
||||||
private $_env = array();
|
private $_env = array();
|
||||||
|
|
||||||
/**
|
|
||||||
* Domain suffix.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $_tld = 'loc';
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Document root path in PHP docker
|
* Document root path in PHP docker
|
||||||
@ -83,12 +76,6 @@ class Docker
|
|||||||
$tmp = explode('=', $var);
|
$tmp = explode('=', $var);
|
||||||
$this->_env[$tmp[0]] = $tmp[1];
|
$this->_env[$tmp[0]] = $tmp[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the TLD suffix (domain ending) for virtual hosts
|
|
||||||
// Note: If this is changed it currently also needs to be changed
|
|
||||||
// in each webserver's configuration file in .devilbox/<webserver>/02-vhost-mass.conf
|
|
||||||
$this->_tld = $GLOBALS['TLD_SUFFIX'];
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -113,15 +100,6 @@ class Docker
|
|||||||
return $this->_env[$variable];
|
return $this->_env[$variable];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get tld suffix.
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getTld()
|
|
||||||
{
|
|
||||||
return $this->_tld;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get HTTP port.
|
* Get HTTP port.
|
||||||
@ -227,8 +205,8 @@ class Docker
|
|||||||
|
|
||||||
$vhosts[] = array(
|
$vhosts[] = array(
|
||||||
'name' => $directory,
|
'name' => $directory,
|
||||||
'domain' => $directory .'.' . $this->_tld,
|
'domain' => $directory .'.' . $this->getEnv('TLD_SUFFIX'),
|
||||||
'href' => 'http://' . $directory . '.' . $this->_tld
|
'href' => 'http://' . $directory . '.' . $this->getEnv('TLD_SUFFIX')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -246,14 +224,14 @@ class Docker
|
|||||||
{
|
{
|
||||||
$docRoot = $this->_doc_root;
|
$docRoot = $this->_doc_root;
|
||||||
$htdocs = $docRoot . DIRECTORY_SEPARATOR . $vhost . DIRECTORY_SEPARATOR . 'htdocs';
|
$htdocs = $docRoot . DIRECTORY_SEPARATOR . $vhost . DIRECTORY_SEPARATOR . 'htdocs';
|
||||||
$domain = $vhost . '.' . $this->_tld;
|
$domain = $vhost . '.' . $this->getEnv('TLD_SUFFIX');
|
||||||
$url = 'http://'.$domain;
|
$url = 'http://'.$domain;
|
||||||
$error = array();
|
$error = array();
|
||||||
|
|
||||||
|
|
||||||
// 1. Check htdocs folder
|
// 1. Check htdocs folder
|
||||||
if (!$this->_is_valid_dir($htdocs)) {
|
if (!$this->_is_valid_dir($htdocs)) {
|
||||||
$error[] = 'Missing <strong>htdocs</strong> directory in: <strong>'.$this->getEnv('HOST_PATH_TO_WWW_DOCROOTS').'/'.$vhost.'/</strong>';
|
$error[] = 'Missing <strong>htdocs</strong> directory in: <strong>'.$this->getEnv('HOST_PATH_HTTPD_DATADIR').'/'.$vhost.'/</strong>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($GLOBALS['ENABLE_VHOST_DNS_CHECK']) {
|
if ($GLOBALS['ENABLE_VHOST_DNS_CHECK']) {
|
||||||
|
@ -151,6 +151,10 @@ class Php extends _Base implements _iBase
|
|||||||
|
|
||||||
return $this->egrep('/[0-9.]+/', isset($output[0]) ? $output[0] : '');
|
return $this->egrep('/[0-9.]+/', isset($output[0]) ? $output[0] : '');
|
||||||
}
|
}
|
||||||
|
public function getTldSuffix()
|
||||||
|
{
|
||||||
|
return getenv('TLD_SUFFIX');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************************
|
/*********************************************************************************
|
||||||
|
@ -57,6 +57,12 @@ services:
|
|||||||
##
|
##
|
||||||
- TIMEZONE
|
- TIMEZONE
|
||||||
|
|
||||||
|
##
|
||||||
|
## TLD SUffix
|
||||||
|
##
|
||||||
|
- TLD_SUFFIX=${TLD_SUFFIX:-loc}
|
||||||
|
- DNS_CHECK_TIMEOUT=${DNS_CHECK_TIMEOUT:-1}
|
||||||
|
|
||||||
##
|
##
|
||||||
## PHP Xdebug
|
## PHP Xdebug
|
||||||
##
|
##
|
||||||
|
32
env-example
32
env-example
@ -47,6 +47,38 @@ DEVILBOX_PATH=.
|
|||||||
LOCAL_LISTEN_ADDR=127.0.0.1:
|
LOCAL_LISTEN_ADDR=127.0.0.1:
|
||||||
|
|
||||||
|
|
||||||
|
###
|
||||||
|
### This is the domain suffix your projects will be made available
|
||||||
|
### with mass-virtual-hosting.
|
||||||
|
### It is also required for the internal DNS server to be setup.
|
||||||
|
###
|
||||||
|
### Note: Only ALPHA ([a-zA-Z]+) characters are supported.
|
||||||
|
###
|
||||||
|
### Example:
|
||||||
|
### TLD_SUFFIX=loc
|
||||||
|
### Makes your project available under xxxx.loc
|
||||||
|
###
|
||||||
|
### Example:
|
||||||
|
### TLD_SUFFIX=local
|
||||||
|
### Makes your project available under xxxx.local
|
||||||
|
###
|
||||||
|
TLD_SUFFIX=loc
|
||||||
|
|
||||||
|
|
||||||
|
###
|
||||||
|
### TLD_SUFFIX domains are checked if they are set in the
|
||||||
|
### host computer /etc/hosts or available via attached DNS server.
|
||||||
|
### Timeout is done on vhosts.php (intranet) via ajax calls.
|
||||||
|
### In order to keep performance, set this to a low value.
|
||||||
|
### DNS checks might not succeed in time on slow machines.
|
||||||
|
### If DNS is valid, but timeout is expired, set this to a higher value.
|
||||||
|
###
|
||||||
|
### DNS_CHECK_TIMEOUT value is how many seconds to time out
|
||||||
|
### Default is to timeout after 1 second (DNS_CHECK_TIMEOUT=1)
|
||||||
|
###
|
||||||
|
DNS_CHECK_TIMEOUT=1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
###
|
###
|
||||||
|
Loading…
x
Reference in New Issue
Block a user