mirror of
https://github.com/cytopia/devilbox.git
synced 2024-12-21 21:57:47 +00:00
Merge pull request #442 from cytopia/devilbox-ui
Devilbox Web UI: Vhost overview
This commit is contained in:
commit
3b73b1c5e5
66
.devilbox/www/htdocs/info_vhostgen.php
Normal file
66
.devilbox/www/htdocs/info_vhostgen.php
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
<?php require '../config.php'; ?>
|
||||||
|
<?php loadClass('Helper')->authPage(); ?>
|
||||||
|
<?php
|
||||||
|
if (!isset($_GET['name'])) {
|
||||||
|
loadClass('Helper')->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);
|
||||||
|
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<?php echo loadClass('Html')->getHead(true); ?>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<?php echo loadClass('Html')->getNavbar(); ?>
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
|
||||||
|
<h1>vhost-gen: <?php echo $vhost;?></h1>
|
||||||
|
<br/>
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<?php if (!$found): ?>
|
||||||
|
<p>The Virtual Host "<?php echo $vhost; ?>" does not exist.</p>
|
||||||
|
<?php else: ?>
|
||||||
|
<?php $tpl = loadClass('Httpd')->getVhostgenTemplatePath($vhost); ?>
|
||||||
|
<?php if (!$tpl): ?>
|
||||||
|
<p>No custom vhost-gen configuration found for "<?php echo $vhost; ?>".</p>
|
||||||
|
<?php else: ?>
|
||||||
|
<p>Note: If the resulting virtual host config does not reflect the vhost-gen template changes, you will need to restart the Devilbox.</p>
|
||||||
|
<a href="/vhosts.php"><i class="fa fa-chevron-left" aria-hidden="true"></i> Overview</a><br/>
|
||||||
|
<br/><h3>virtual host config</h3><br/>
|
||||||
|
<a title="Virtual host: <?php echo $vHost['name'];?>.conf" target="_blank" href="/vhost.d/<?php echo $vhost;?>.conf">
|
||||||
|
<i class="fa fa-external-link" aria-hidden="true"></i> <?php echo $vhost;?>.conf
|
||||||
|
</a>
|
||||||
|
<br/><br/><h3>vhost-gen config</h3><br/>
|
||||||
|
<code><?php echo $tpl; ?></code><br/><br/>
|
||||||
|
<?php $lines = file($tpl); ?>
|
||||||
|
<pre style="border: 1px solid black; padding:5px;"><code><?php foreach ($lines as $line): ?><?php echo $line; ?><?php endforeach; ?></code></pre>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div><!-- /.container -->
|
||||||
|
|
||||||
|
<?php echo loadClass('Html')->getFooter(); ?>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -3,7 +3,7 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<?php echo loadClass('Html')->getHead(); ?>
|
<?php echo loadClass('Html')->getHead(true); ?>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
@ -24,6 +24,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th>Project</th>
|
<th>Project</th>
|
||||||
<th>DocumentRoot</th>
|
<th>DocumentRoot</th>
|
||||||
|
<th>Config</th>
|
||||||
<th>Valid</th>
|
<th>Valid</th>
|
||||||
<th>URL</th>
|
<th>URL</th>
|
||||||
</tr>
|
</tr>
|
||||||
@ -40,6 +41,12 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td><?php echo $vHost['name'];?></td>
|
<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('Helper')->getEnv('HOST_PATH_HTTPD_DATADIR');?>/<?php echo $vHost['name'];?>/<?php echo loadClass('Helper')->getEnv('HTTPD_DOCROOT_DIR');?></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): ?>
|
||||||
|
<a title="vhost-gen: <?php echo basename($vhostGen);?> for <?php echo $vHost['name'];?>" href="/info_vhostgen.php?name=<?php echo $vHost['name'];?>"><i class="fa fa-filter" aria-hidden="true"></i></a>
|
||||||
|
<?php endif; ?>
|
||||||
|
</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>
|
||||||
|
@ -165,6 +165,35 @@ class Httpd extends BaseClass implements BaseInterface
|
|||||||
return $version;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************************
|
/*********************************************************************************
|
||||||
|
128
.tests/intra-tests/vhosts.sh
Executable file
128
.tests/intra-tests/vhosts.sh
Executable file
@ -0,0 +1,128 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
set -u
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# NOTE: Parsing curl to tac to circumnvent "failed writing body"
|
||||||
|
# https://stackoverflow.com/questions/16703647/why-curl-return-and-error-23-failed-writing-body
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
|
VHOST="${1:-vhost-tests}"
|
||||||
|
|
||||||
|
VHOST_GEN_URL="/info_vhostgen.php?name=${VHOST}"
|
||||||
|
VHOST_URL="/vhost.d/${VHOST}.conf"
|
||||||
|
|
||||||
|
|
||||||
|
###
|
||||||
|
### vhost.d config
|
||||||
|
###
|
||||||
|
|
||||||
|
printf "[TEST] vhost.d config link available for ${VHOST}"
|
||||||
|
# 1st Try
|
||||||
|
if ! curl -sS localhost/vhosts.php | tac | tac | grep "${VHOST}" | grep -q "${VHOST_URL}"; then
|
||||||
|
# 2nd Try
|
||||||
|
sleep 1
|
||||||
|
if ! curl -sS localhost/vhosts.php | tac | tac | grep "${VHOST}" | grep -q "${VHOST_URL}"; then
|
||||||
|
# 3rd Try
|
||||||
|
sleep 1
|
||||||
|
if ! curl -sS localhost/vhosts.php | tac | tac | grep "${VHOST}" | grep -q "${VHOST_URL}"; then
|
||||||
|
printf "\r[FAIL] vhost.d config link available for ${VHOST}\n"
|
||||||
|
curl -sS localhost/vhosts.php | tac | tac | grep -E "${VHOST}|vhostgen" || true
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
printf "\r[OK] vhost.d config link available for ${VHOST} (3 rounds)\n"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
printf "\r[OK] vhost.d config link available for ${VHOST} (2 rounds)\n"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
printf "\r[OK] vhost.d config link available for ${VHOST} (1 round)\n"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
###
|
||||||
|
### vhost-gen config
|
||||||
|
###
|
||||||
|
|
||||||
|
printf "[TEST] vhost-gen config link available for ${VHOST}"
|
||||||
|
# 1st Try
|
||||||
|
if ! curl -sS localhost/vhosts.php | tac | tac | grep "${VHOST}" | grep "vhost-gen" | grep -q "${VHOST_GEN_URL}"; then
|
||||||
|
# 2nd Try
|
||||||
|
sleep 1
|
||||||
|
if ! curl -sS localhost/vhosts.php | tac | tac | grep "${VHOST}" | grep "vhost-gen" | grep -q "${VHOST_GEN_URL}"; then
|
||||||
|
# 3rd Try
|
||||||
|
sleep 1
|
||||||
|
if ! curl -sS localhost/vhosts.php | tac | tac | grep "${VHOST}" | grep "vhost-gen" | grep -q "${VHOST_GEN_URL}"; then
|
||||||
|
printf "\r[FAIL] vhost-gen config link available for ${VHOST}\n"
|
||||||
|
curl -sS localhost/vhosts.php | tac | tac | grep -E "${VHOST}|vhostgen|vhost-gen" || true
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
printf "\r[OK] vhost-gen config link available for ${VHOST} (3 rounds)\n"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
printf "\r[OK] vhost-gen config link available for ${VHOST} (2 rounds)\n"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
printf "\r[OK] vhost-gen config link available for ${VHOST} (1 round)\n"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
###
|
||||||
|
### vhost.d config
|
||||||
|
###
|
||||||
|
|
||||||
|
printf "[TEST] vhost.d config available for ${VHOST}"
|
||||||
|
# 1st Try
|
||||||
|
if ! curl -sS localhost${VHOST_URL} | tac | tac | grep -q "${VHOST}-access.log";then
|
||||||
|
# 2nd Try
|
||||||
|
sleep 1
|
||||||
|
if ! curl -sS localhost${VHOST_URL} | tac | tac | grep -q "${VHOST}-access.log";then
|
||||||
|
# 3rd Try
|
||||||
|
sleep 1
|
||||||
|
if ! curl -sS localhost${VHOST_URL} | tac | tac | grep -q "${VHOST}-access.log";then
|
||||||
|
printf "\r[FAIL] vhost.d config available for ${VHOST}\n"
|
||||||
|
curl -sS localhost${VHOST_URL} || true
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
printf "\r[OK] vhost.d config available for ${VHOST} (3 rounds)\n"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
printf "\r[OK] vhost.d config available for ${VHOST} (2 rounds)\n"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
printf "\r[OK] vhost.d config available for ${VHOST} (1 round)\n"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
###
|
||||||
|
### vhostgen config
|
||||||
|
###
|
||||||
|
|
||||||
|
printf "[TEST] vhost-gen config available for ${VHOST}"
|
||||||
|
# 1st Try
|
||||||
|
if ! curl -sS localhost${VHOST_GEN_URL} | tac | tac | grep -q "/shared/httpd/${VHOST}";then
|
||||||
|
# 2nd Try
|
||||||
|
sleep 1
|
||||||
|
if ! curl -sS localhost${VHOST_GEN_URL} | tac | tac | grep -q "/shared/httpd/${VHOST}";then
|
||||||
|
# 3rd Try
|
||||||
|
sleep 1
|
||||||
|
if ! curl -sS localhost${VHOST_GEN_URL} | tac | tac | grep -q "/shared/httpd/${VHOST}";then
|
||||||
|
printf "\r[FAIL] vhost-gen config available for ${VHOST}\n"
|
||||||
|
curl -sS localhost${VHOST_GEN_URL} || true
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
printf "\r[OK] vhost-gen config available for ${VHOST} (3 rounds)\n"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
printf "\r[OK] vhost-gen config available for ${VHOST} (2 rounds)\n"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
printf "\r[OK] vhost-gen config available for ${VHOST} (1 round)\n"
|
||||||
|
fi
|
||||||
|
|
161
.tests/vhost-tests/.devilbox/apache22.yml
Normal file
161
.tests/vhost-tests/.devilbox/apache22.yml
Normal file
@ -0,0 +1,161 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
# Apache 2.2 vHost Template defintion for vhost-gen.py
|
||||||
|
#
|
||||||
|
# The 'feature' section contains optional features that can be enabled via
|
||||||
|
# conf.yml and will then be replaced into the main vhost ('structure' section)
|
||||||
|
# into their corresponding position:
|
||||||
|
#
|
||||||
|
# __XDOMAIN_REQ__
|
||||||
|
# __PHP_FPM__
|
||||||
|
# __ALIASES__
|
||||||
|
# __DENIES__
|
||||||
|
# __STATUS__
|
||||||
|
#
|
||||||
|
# The features itself also contain variables to be adjusted in conf.yml
|
||||||
|
# and will then be replaced in their corresponding feature section
|
||||||
|
# before being replaced into the vhost section (if enabled):
|
||||||
|
#
|
||||||
|
# PHP-FPM:
|
||||||
|
# __PHP_ADDR__
|
||||||
|
# __PHP_PORT__
|
||||||
|
# XDomain:
|
||||||
|
# __REGEX__
|
||||||
|
# Alias:
|
||||||
|
# __REGEX__
|
||||||
|
# __PATH__
|
||||||
|
# Deny:
|
||||||
|
# __REGEX__
|
||||||
|
# Status:
|
||||||
|
# __REGEX__
|
||||||
|
#
|
||||||
|
# Variables to be replaced directly in the vhost configuration can also be set
|
||||||
|
# in conf.yml and include:
|
||||||
|
# __VHOST_NAME__
|
||||||
|
# __DOCUMENT_ROOT__
|
||||||
|
# __INDEX__
|
||||||
|
# __ACCESS_LOG__
|
||||||
|
# __ERROR_LOG__
|
||||||
|
# __PHP_ADDR__
|
||||||
|
# __PHP_PORT__
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
|
###
|
||||||
|
### Basic vHost skeleton
|
||||||
|
###
|
||||||
|
vhost: |
|
||||||
|
<VirtualHost __DEFAULT_VHOST__:__PORT__>
|
||||||
|
ServerName __VHOST_NAME__
|
||||||
|
|
||||||
|
CustomLog "__ACCESS_LOG__" combined
|
||||||
|
ErrorLog "__ERROR_LOG__"
|
||||||
|
|
||||||
|
__REDIRECT__
|
||||||
|
__SSL__
|
||||||
|
__VHOST_DOCROOT__
|
||||||
|
__VHOST_RPROXY__
|
||||||
|
__PHP_FPM__
|
||||||
|
__ALIASES__
|
||||||
|
__DENIES__
|
||||||
|
__SERVER_STATUS__
|
||||||
|
# Custom directives
|
||||||
|
__CUSTOM__
|
||||||
|
</VirtualHost>
|
||||||
|
|
||||||
|
###
|
||||||
|
### vHost Type (normal or reverse proxy)
|
||||||
|
###
|
||||||
|
vhost_type:
|
||||||
|
# Normal vHost (-p)
|
||||||
|
docroot: |
|
||||||
|
# Define the vhost to serve files
|
||||||
|
DocumentRoot "__DOCUMENT_ROOT__"
|
||||||
|
<Directory "__DOCUMENT_ROOT__">
|
||||||
|
DirectoryIndex __INDEX__
|
||||||
|
|
||||||
|
AllowOverride All
|
||||||
|
Options All
|
||||||
|
|
||||||
|
RewriteEngine on
|
||||||
|
RewriteBase /
|
||||||
|
|
||||||
|
Order allow,deny
|
||||||
|
Allow from all
|
||||||
|
</Directory>
|
||||||
|
|
||||||
|
# Reverse Proxy (-r)
|
||||||
|
rproxy: |
|
||||||
|
# Define the vhost to reverse proxy
|
||||||
|
ProxyRequests off
|
||||||
|
ProxyPass __LOCATION__ __PROXY_PROTO://__PROXY_ADDR__:__PROXY_PORT__
|
||||||
|
ProxyHTMLURLMap __PROXY_PROTO://__PROXY_ADDR__:__PROXY_PORT__ __LOCATION__
|
||||||
|
<location __LOCATION__>
|
||||||
|
ProxyPassReverse /
|
||||||
|
SetOutputFilter proxy-html
|
||||||
|
ProxyHTMLURLMap / __LOCATION__
|
||||||
|
ProxyHTMLURLMap __LOCATION__ __LOCATION__
|
||||||
|
RequestHeader unset Accept-Encoding
|
||||||
|
</location>
|
||||||
|
|
||||||
|
|
||||||
|
###
|
||||||
|
### Optional features to be enabled in vHost
|
||||||
|
###
|
||||||
|
features:
|
||||||
|
|
||||||
|
# SSL Configuration
|
||||||
|
ssl: |
|
||||||
|
SSLEngine on
|
||||||
|
SSLCertificateFile "__SSL_PATH_CRT__"
|
||||||
|
SSLCertificateKeyFile "__SSL_PATH_KEY__"
|
||||||
|
SSLProtocol __SSL_PROTOCOLS__
|
||||||
|
SSLHonorCipherOrder __SSL_HONOR_CIPHER_ORDER__
|
||||||
|
SSLCipherSuite __SSL_CIPHERS__
|
||||||
|
|
||||||
|
# Redirect to SSL directive
|
||||||
|
redirect: |
|
||||||
|
RedirectMatch (.*) https://__VHOST_NAME__:__SSL_PORT__$1
|
||||||
|
|
||||||
|
# PHP-FPM will not be applied to a reverse proxy!
|
||||||
|
php_fpm: |
|
||||||
|
# PHP-FPM Definition
|
||||||
|
ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://__PHP_ADDR__:__PHP_PORT____DOCUMENT_ROOT__/$1 timeout=__PHP_TIMEOUT__
|
||||||
|
|
||||||
|
alias: |
|
||||||
|
# Alias Definition
|
||||||
|
Alias "__ALIAS__" "__PATH____ALIAS__"
|
||||||
|
<Location "__ALIAS__">
|
||||||
|
__XDOMAIN_REQ__
|
||||||
|
</Location>
|
||||||
|
<Directory "__PATH____ALIAS__">
|
||||||
|
Order allow,deny
|
||||||
|
Allow from all
|
||||||
|
</Directory>
|
||||||
|
|
||||||
|
deny: |
|
||||||
|
# Deny Definition
|
||||||
|
<FilesMatch "__REGEX__">
|
||||||
|
Order allow,deny
|
||||||
|
Deny from all
|
||||||
|
</FilesMatch>
|
||||||
|
|
||||||
|
server_status: |
|
||||||
|
# Status Page
|
||||||
|
<Location __REGEX__>
|
||||||
|
SetHandler server-status
|
||||||
|
Order allow,deny
|
||||||
|
Allow from all
|
||||||
|
</Location>
|
||||||
|
|
||||||
|
xdomain_request: |
|
||||||
|
# Allow cross domain request from these hosts
|
||||||
|
SetEnvIf Origin "__REGEX__" AccessControlAllowOrigin=$0
|
||||||
|
Header add Access-Control-Allow-Origin %{AccessControlAllowOrigin}e env=AccessControlAllowOrigin
|
||||||
|
Header always set Access-Control-Allow-Methods "POST, GET, OPTIONS, DELETE, PUT"
|
||||||
|
Header always set Access-Control-Max-Age "0"
|
||||||
|
Header always set Access-Control-Allow-Headers "x-requested-with, Content-Type, origin, authorization, accept, client-security-token"
|
||||||
|
# Added a rewrite to respond with a 200 SUCCESS on every OPTIONS request.
|
||||||
|
RewriteEngine On
|
||||||
|
RewriteCond %{REQUEST_METHOD} OPTIONS
|
||||||
|
RewriteRule ^(.*)$ $1 [R=200,L]
|
183
.tests/vhost-tests/.devilbox/apache24.yml
Normal file
183
.tests/vhost-tests/.devilbox/apache24.yml
Normal file
@ -0,0 +1,183 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
# Apache 2.4 vHost Template defintion for vhost-gen.py
|
||||||
|
#
|
||||||
|
# The 'feature' section contains optional features that can be enabled via
|
||||||
|
# conf.yml and will then be replaced into the main vhost ('structure' section)
|
||||||
|
# into their corresponding position:
|
||||||
|
#
|
||||||
|
# __XDOMAIN_REQ__
|
||||||
|
# __PHP_FPM__
|
||||||
|
# __ALIASES__
|
||||||
|
# __DENIES__
|
||||||
|
# __STATUS__
|
||||||
|
#
|
||||||
|
# The features itself also contain variables to be adjusted in conf.yml
|
||||||
|
# and will then be replaced in their corresponding feature section
|
||||||
|
# before being replaced into the vhost section (if enabled):
|
||||||
|
#
|
||||||
|
# PHP-FPM:
|
||||||
|
# __PHP_ADDR__
|
||||||
|
# __PHP_PORT__
|
||||||
|
# XDomain:
|
||||||
|
# __REGEX__
|
||||||
|
# Alias:
|
||||||
|
# __REGEX__
|
||||||
|
# __PATH__
|
||||||
|
# Deny:
|
||||||
|
# __REGEX__
|
||||||
|
# Status:
|
||||||
|
# __REGEX__
|
||||||
|
#
|
||||||
|
# Variables to be replaced directly in the vhost configuration can also be set
|
||||||
|
# in conf.yml and include:
|
||||||
|
# __VHOST_NAME__
|
||||||
|
# __DOCUMENT_ROOT__
|
||||||
|
# __INDEX__
|
||||||
|
# __ACCESS_LOG__
|
||||||
|
# __ERROR_LOG__
|
||||||
|
# __PHP_ADDR__
|
||||||
|
# __PHP_PORT__
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
|
###
|
||||||
|
### Basic vHost skeleton
|
||||||
|
###
|
||||||
|
vhost: |
|
||||||
|
<VirtualHost __DEFAULT_VHOST__:__PORT__>
|
||||||
|
ServerName __VHOST_NAME__
|
||||||
|
|
||||||
|
CustomLog "__ACCESS_LOG__" combined
|
||||||
|
ErrorLog "__ERROR_LOG__"
|
||||||
|
|
||||||
|
__REDIRECT__
|
||||||
|
__SSL__
|
||||||
|
__VHOST_DOCROOT__
|
||||||
|
__VHOST_RPROXY__
|
||||||
|
__PHP_FPM__
|
||||||
|
__ALIASES__
|
||||||
|
__DENIES__
|
||||||
|
__SERVER_STATUS__
|
||||||
|
# Custom directives
|
||||||
|
__CUSTOM__
|
||||||
|
</VirtualHost>
|
||||||
|
|
||||||
|
###
|
||||||
|
### vHost Type (normal or reverse proxy)
|
||||||
|
###
|
||||||
|
vhost_type:
|
||||||
|
# Normal vHost (-p)
|
||||||
|
docroot: |
|
||||||
|
# Define the vhost to serve files
|
||||||
|
DocumentRoot "__DOCUMENT_ROOT__"
|
||||||
|
<Directory "__DOCUMENT_ROOT__">
|
||||||
|
DirectoryIndex __INDEX__
|
||||||
|
|
||||||
|
AllowOverride All
|
||||||
|
Options All
|
||||||
|
|
||||||
|
RewriteEngine on
|
||||||
|
RewriteBase /
|
||||||
|
|
||||||
|
Order allow,deny
|
||||||
|
Allow from all
|
||||||
|
Require all granted
|
||||||
|
</Directory>
|
||||||
|
|
||||||
|
# Reverse Proxy (-r)
|
||||||
|
rproxy: |
|
||||||
|
# Define the vhost to reverse proxy
|
||||||
|
ProxyRequests off
|
||||||
|
ProxyPass __LOCATION__ __PROXY_PROTO://__PROXY_ADDR__:__PROXY_PORT__
|
||||||
|
ProxyHTMLURLMap __PROXY_PROTO://__PROXY_ADDR__:__PROXY_PORT__ __LOCATION__
|
||||||
|
<location __LOCATION__>
|
||||||
|
ProxyPassReverse /
|
||||||
|
SetOutputFilter proxy-html
|
||||||
|
ProxyHTMLURLMap / __LOCATION__
|
||||||
|
ProxyHTMLURLMap __LOCATION__ __LOCATION__
|
||||||
|
RequestHeader unset Accept-Encoding
|
||||||
|
</location>
|
||||||
|
|
||||||
|
|
||||||
|
###
|
||||||
|
### Optional features to be enabled in vHost
|
||||||
|
###
|
||||||
|
features:
|
||||||
|
|
||||||
|
# SSL Configuration
|
||||||
|
ssl: |
|
||||||
|
SSLEngine on
|
||||||
|
SSLCertificateFile "__SSL_PATH_CRT__"
|
||||||
|
SSLCertificateKeyFile "__SSL_PATH_KEY__"
|
||||||
|
SSLProtocol __SSL_PROTOCOLS__
|
||||||
|
SSLHonorCipherOrder __SSL_HONOR_CIPHER_ORDER__
|
||||||
|
SSLCipherSuite __SSL_CIPHERS__
|
||||||
|
|
||||||
|
# Redirect to SSL directive
|
||||||
|
redirect: |
|
||||||
|
RedirectMatch (.*) https://__VHOST_NAME__:__SSL_PORT__$1
|
||||||
|
|
||||||
|
# PHP-FPM will not be applied to a reverse proxy!
|
||||||
|
php_fpm: |
|
||||||
|
# In case for PHP-FPM 5.2 compatibility use 'GENERIC' instead of 'FPM'
|
||||||
|
# https://httpd.apache.org/docs/2.4/mod/mod_proxy_fcgi.html#proxyfcgibackendtype
|
||||||
|
ProxyFCGIBackendType FPM
|
||||||
|
|
||||||
|
# PHP-FPM Definition
|
||||||
|
<FilesMatch \.php$>
|
||||||
|
Require all granted
|
||||||
|
SetHandler proxy:fcgi://__PHP_ADDR__:__PHP_PORT__
|
||||||
|
</FilesMatch>
|
||||||
|
|
||||||
|
<Proxy "fcgi://__PHP_ADDR__:__PHP_PORT__/">
|
||||||
|
ProxySet timeout=__PHP_TIMEOUT__
|
||||||
|
ProxySet connectiontimeout=__PHP_TIMEOUT__
|
||||||
|
</Proxy>
|
||||||
|
|
||||||
|
# If the php file doesn't exist, disable the proxy handler.
|
||||||
|
# This will allow .htaccess rewrite rules to work and
|
||||||
|
# the client will see the default 404 page of Apache
|
||||||
|
RewriteCond %{REQUEST_FILENAME} \.php$
|
||||||
|
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI} !-f
|
||||||
|
RewriteRule (.*) - [H=text/html]
|
||||||
|
|
||||||
|
alias: |
|
||||||
|
# Alias Definition
|
||||||
|
Alias "__ALIAS__" "__PATH____ALIAS__"
|
||||||
|
<Location "__ALIAS__">
|
||||||
|
__XDOMAIN_REQ__
|
||||||
|
</Location>
|
||||||
|
<Directory "__PATH____ALIAS__">
|
||||||
|
Order allow,deny
|
||||||
|
Allow from all
|
||||||
|
Require all granted
|
||||||
|
</Directory>
|
||||||
|
|
||||||
|
deny: |
|
||||||
|
# Deny Definition
|
||||||
|
<FilesMatch "__REGEX__">
|
||||||
|
Order allow,deny
|
||||||
|
Deny from all
|
||||||
|
</FilesMatch>
|
||||||
|
|
||||||
|
server_status: |
|
||||||
|
# Status Page
|
||||||
|
<Location __REGEX__>
|
||||||
|
SetHandler server-status
|
||||||
|
Order allow,deny
|
||||||
|
Allow from all
|
||||||
|
Require all granted
|
||||||
|
</Location>
|
||||||
|
|
||||||
|
xdomain_request: |
|
||||||
|
# Allow cross domain request from these hosts
|
||||||
|
SetEnvIf Origin "__REGEX__" AccessControlAllowOrigin=$0
|
||||||
|
Header add Access-Control-Allow-Origin %{AccessControlAllowOrigin}e env=AccessControlAllowOrigin
|
||||||
|
Header always set Access-Control-Allow-Methods "POST, GET, OPTIONS, DELETE, PUT"
|
||||||
|
Header always set Access-Control-Max-Age "0"
|
||||||
|
Header always set Access-Control-Allow-Headers "x-requested-with, Content-Type, origin, authorization, accept, client-security-token"
|
||||||
|
# Added a rewrite to respond with a 200 SUCCESS on every OPTIONS request.
|
||||||
|
RewriteEngine On
|
||||||
|
RewriteCond %{REQUEST_METHOD} OPTIONS
|
||||||
|
RewriteRule ^(.*)$ $1 [R=200,L]
|
157
.tests/vhost-tests/.devilbox/nginx.yml
Normal file
157
.tests/vhost-tests/.devilbox/nginx.yml
Normal file
@ -0,0 +1,157 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
# Nginx vHost Template defintion for vhost-gen.py
|
||||||
|
#
|
||||||
|
# The 'feature' section contains optional features that can be enabled via
|
||||||
|
# conf.yml and will then be replaced into the main vhost ('structure' section)
|
||||||
|
# into their corresponding position:
|
||||||
|
#
|
||||||
|
# __XDOMAIN_REQ__
|
||||||
|
# __PHP_FPM__
|
||||||
|
# __ALIASES__
|
||||||
|
# __DENIES__
|
||||||
|
# __STATUS__
|
||||||
|
#
|
||||||
|
# The features itself also contain variables to be adjusted in conf.yml
|
||||||
|
# and will then be replaced in their corresponding feature section
|
||||||
|
# before being replaced into the vhost section (if enabled):
|
||||||
|
#
|
||||||
|
# PHP-FPM:
|
||||||
|
# __PHP_ADDR__
|
||||||
|
# __PHP_PORT__
|
||||||
|
# XDomain:
|
||||||
|
# __REGEX__
|
||||||
|
# Alias:
|
||||||
|
# __REGEX__
|
||||||
|
# __PATH__
|
||||||
|
# Deny:
|
||||||
|
# __REGEX__
|
||||||
|
# Status:
|
||||||
|
# __REGEX__
|
||||||
|
#
|
||||||
|
# Variables to be replaced directly in the vhost configuration can also be set
|
||||||
|
# in conf.yml and include:
|
||||||
|
# __VHOST_NAME__
|
||||||
|
# __DOCUMENT_ROOT__
|
||||||
|
# __INDEX__
|
||||||
|
# __ACCESS_LOG__
|
||||||
|
# __ERROR_LOG__
|
||||||
|
# __PHP_ADDR__
|
||||||
|
# __PHP_PORT__
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
|
###
|
||||||
|
### Basic vHost skeleton
|
||||||
|
###
|
||||||
|
vhost: |
|
||||||
|
server {
|
||||||
|
listen __PORT____DEFAULT_VHOST__;
|
||||||
|
server_name __VHOST_NAME__;
|
||||||
|
|
||||||
|
access_log "__ACCESS_LOG__" combined;
|
||||||
|
error_log "__ERROR_LOG__" warn;
|
||||||
|
|
||||||
|
__REDIRECT__
|
||||||
|
__SSL__
|
||||||
|
__VHOST_DOCROOT__
|
||||||
|
__VHOST_RPROXY__
|
||||||
|
__PHP_FPM__
|
||||||
|
__ALIASES__
|
||||||
|
__DENIES__
|
||||||
|
__SERVER_STATUS__
|
||||||
|
# Custom directives
|
||||||
|
__CUSTOM__
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
###
|
||||||
|
### vHost Type (normal or reverse proxy)
|
||||||
|
###
|
||||||
|
vhost_type:
|
||||||
|
# Normal vHost (-p)
|
||||||
|
docroot: |
|
||||||
|
# Define the vhost to serve files
|
||||||
|
root "__DOCUMENT_ROOT__";
|
||||||
|
index __INDEX__;
|
||||||
|
|
||||||
|
# Reverse Proxy (-r)
|
||||||
|
rproxy: |
|
||||||
|
# Define the vhost to reverse proxy
|
||||||
|
location __LOCATION__ {
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_pass __PROXY_PROTO__://__PROXY_ADDR__:__PROXY_PORT__;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
###
|
||||||
|
### Optional features to be enabled in vHost
|
||||||
|
###
|
||||||
|
features:
|
||||||
|
|
||||||
|
# SSL Configuration
|
||||||
|
ssl: |
|
||||||
|
ssl_certificate __SSL_PATH_CRT__;
|
||||||
|
ssl_certificate_key __SSL_PATH_KEY__;
|
||||||
|
ssl_protocols __SSL_PROTOCOLS__;
|
||||||
|
ssl_prefer_server_ciphers __SSL_HONOR_CIPHER_ORDER__;
|
||||||
|
ssl_ciphers __SSL_CIPHERS__;
|
||||||
|
|
||||||
|
# Redirect to SSL directive
|
||||||
|
redirect: |
|
||||||
|
return 301 https://__VHOST_NAME__:__SSL_PORT__$request_uri;
|
||||||
|
|
||||||
|
# PHP-FPM will not be applied to a reverse proxy!
|
||||||
|
php_fpm: |
|
||||||
|
# PHP-FPM Definition
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ /index.php$is_args$args;
|
||||||
|
}
|
||||||
|
location ~ \.php?$ {
|
||||||
|
try_files $uri = 404;
|
||||||
|
include fastcgi_params;
|
||||||
|
|
||||||
|
# https://stackoverflow.com/questions/1733306/nginx-errors-readv-and-recv-failed/51457613#51457613
|
||||||
|
fastcgi_keep_conn off;
|
||||||
|
|
||||||
|
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||||
|
fastcgi_split_path_info ^(.+\.php)(.*)$;
|
||||||
|
|
||||||
|
fastcgi_pass __PHP_ADDR__:__PHP_PORT__;
|
||||||
|
fastcgi_read_timeout __PHP_TIMEOUT__;
|
||||||
|
|
||||||
|
fastcgi_index index.php;
|
||||||
|
fastcgi_intercept_errors on;
|
||||||
|
}
|
||||||
|
|
||||||
|
alias: |
|
||||||
|
# Alias Definition
|
||||||
|
location ~ __ALIAS__ {
|
||||||
|
root __PATH__;
|
||||||
|
__XDOMAIN_REQ__
|
||||||
|
}
|
||||||
|
|
||||||
|
deny: |
|
||||||
|
# Deny Definition
|
||||||
|
location ~ __REGEX__ {
|
||||||
|
deny all;
|
||||||
|
}
|
||||||
|
|
||||||
|
server_status: |
|
||||||
|
# Status Page
|
||||||
|
location ~ __REGEX__ {
|
||||||
|
stub_status on;
|
||||||
|
access_log off;
|
||||||
|
}
|
||||||
|
|
||||||
|
xdomain_request: |
|
||||||
|
# Allow cross domain request from these hosts
|
||||||
|
if ( $http_origin ~* (__REGEX__) ) {
|
||||||
|
add_header "Access-Control-Allow-Origin" "$http_origin";
|
||||||
|
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
|
||||||
|
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
|
||||||
|
add_header 'Access-Control-Expose-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
|
||||||
|
add_header 'Access-Control-Max-Age' 0;
|
||||||
|
return 200;
|
||||||
|
}
|
@ -206,7 +206,7 @@ services:
|
|||||||
# Web Server
|
# Web Server
|
||||||
# ------------------------------------------------------------
|
# ------------------------------------------------------------
|
||||||
httpd:
|
httpd:
|
||||||
image: devilbox/${HTTPD_SERVER:-nginx-stable}:0.23
|
image: devilbox/${HTTPD_SERVER:-nginx-stable}:0.24
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user