Rewrite tests to also accompany for rproxy tests

This commit is contained in:
cytopia 2018-12-29 13:11:51 +01:00
parent ccd3f1dbc2
commit 1dfa98446b
No known key found for this signature in database
GPG Key ID: 6D56EDB8695128A2
20 changed files with 211 additions and 558 deletions

9
.gitignore vendored
View File

@ -118,6 +118,15 @@
/docs/linkcheck
*.rst.todo
# Ignore vhost-gen files in test dir (copied on the fly)
/.tests/vhost-tests/my-vhost/.devilbox/apache22.yml
/.tests/vhost-tests/my-vhost/.devilbox/apache24.yml
/.tests/vhost-tests/my-vhost/.devilbox/nginx.yml
/.tests/vhost-tests/my-rhost/.devilbox/apache22.yml
/.tests/vhost-tests/my-rhost/.devilbox/apache24.yml
/.tests/vhost-tests/my-rhost/.devilbox/nginx.yml
# Keep folders
!.keepme

View File

@ -19,8 +19,10 @@ DEVILBOX_NAME = $(shell cd $(DEVILBOX_PATH); basename $$(pwd))
DOCKER_NETWORK = $(shell docker network ls --filter name='$(DEVILBOX_NAME)' --quiet)
# Devilbox test settings
PROJECT = vhost-tests
VHOST = $(PROJECT).loc
PROJECTV = my-vhost
PROJECTR = my-rhost
VHOST = $(PROJECTV).loc
RHOST = $(PROJECTR).loc
# -------------------------------------------------------------------------------------------------
@ -48,11 +50,19 @@ init:
@# Ensure .env file exists
install -m 0644 $(DEVILBOX_PATH)/env-example $(DEVILBOX_PATH)/.env
@# Ensure project vhost-gen files exist (vhost)
install -m 0644 $(DEVILBOX_PATH)/cfg/vhost-gen/apache22.yml-example-vhost $(CURRENT_PATH)/vhost-tests/$(PROJECTV)/.devilbox/apache22.yml
install -m 0644 $(DEVILBOX_PATH)/cfg/vhost-gen/apache24.yml-example-vhost $(CURRENT_PATH)/vhost-tests/$(PROJECTV)/.devilbox/apache24.yml
install -m 0644 $(DEVILBOX_PATH)/cfg/vhost-gen/nginx.yml-example-vhost $(CURRENT_PATH)/vhost-tests/$(PROJECTV)/.devilbox/nginx.yml
@# Ensure project vhost-gen files exist (rhost)
install -m 0644 $(DEVILBOX_PATH)/cfg/vhost-gen/apache22.yml-example-rproxy $(CURRENT_PATH)/vhost-tests/$(PROJECTR)/.devilbox/apache22.yml
install -m 0644 $(DEVILBOX_PATH)/cfg/vhost-gen/apache24.yml-example-rproxy $(CURRENT_PATH)/vhost-tests/$(PROJECTR)/.devilbox/apache24.yml
install -m 0644 $(DEVILBOX_PATH)/cfg/vhost-gen/nginx.yml-example-rproxy $(CURRENT_PATH)/vhost-tests/$(PROJECTR)/.devilbox/nginx.yml
@# Set bind port
echo "HOST_PORT_BIND=53" >> $(DEVILBOX_PATH)/.env
@# Set data dir
sed -i'' 's/^HOST_PATH_HTTPD_DATADIR=/#HOST_PATH_HTTPD_DATADIR=/g' $(DEVILBOX_PATH)/.env
echo "HOST_PATH_HTTPD_DATADIR=.tests" >> $(DEVILBOX_PATH)/.env
echo "HOST_PATH_HTTPD_DATADIR=.tests/vhost-tests" >> $(DEVILBOX_PATH)/.env
@# Set uid/gid
sed -i'' 's/^NEW_UID=.*/NEW_UID=$(MY_UID)/g' $(DEVILBOX_PATH)/.env
sed -i'' 's/^NEW_GID=.*/NEW_GID=$(MY_GID)/g' $(DEVILBOX_PATH)/.env
@ -146,31 +156,7 @@ info:
###
### Run tests
###
test: test-vhost test-intra test-startup
test-intra:
@echo "####################################################################################################"
@echo "# RUNNING TESTS: INTRANET"
@echo "####################################################################################################"
@echo
@# Gather files to test
$(eval SH_FILES := $(notdir $(wildcard $(CURRENT_PATH)/intra-tests/*.sh)))
@$(foreach file,\
$(SH_FILES), \
echo "# ----------------------------------------------------------------------------------------"; \
echo "# [intra] $(file)"; \
echo "# ----------------------------------------------------------------------------------------"; \
cd $(CURRENT_PATH) && $(MAKE) _clean-round >/dev/null; \
if ! $(CURRENT_PATH)/intra-tests/$(file); then \
cd $(CURRENT_PATH) && $(MAKE) _logs; \
exit 1; \
fi; \
echo; \
)
@echo
test: test-vhost test-rhost test-intra test-startup
test-vhost:
@ -183,7 +169,7 @@ test-vhost:
$(eval HTTPD_SERVER := $(shell grep -E '^HTTPD_SERVER' $(DEVILBOX_PATH)/.env | sed 's/.*=//g'))
@# Gather files to test
$(eval PHP_FILES := $(notdir $(wildcard $(CURRENT_PATH)/$(PROJECT)/htdocs/*.php)))
$(eval PHP_FILES := $(notdir $(wildcard $(CURRENT_PATH)/vhost-tests/$(PROJECTV)/htdocs/*.php)))
@echo "# ----------------------------------------------------------------------------------------"
@echo "# [vhost] Test curl HTTP from Docker host"
@ -267,28 +253,92 @@ test-vhost:
@echo "# ----------------------------------------------------------------------------------------"
@$(foreach file,\
$(PHP_FILES), \
printf "[TEST] docker-compose exec php php /shared/httpd/$(PROJECT)/htdocs/$(file)"; \
printf "[TEST] docker-compose exec php php /shared/httpd/$(PROJECTV)/htdocs/$(file)"; \
cd $(CURRENT_PATH) && $(MAKE) _clean-round >/dev/null; \
if ! cd $(DEVILBOX_PATH) && docker-compose exec php php /shared/httpd/$(PROJECT)/htdocs/$(file) | grep -q '^OK$$'; then \
printf "\r[TEST] docker-compose exec php php /shared/httpd/$(PROJECT)/htdocs/$(file)\n"; \
cd $(DEVILBOX_PATH) && docker-composeexec php php /shared/httpd/$(PROJECT)/htdocs/$(file); \
if ! cd $(DEVILBOX_PATH) && docker-compose exec php php /shared/httpd/$(PROJECTV)/htdocs/$(file) | grep -q '^OK$$'; then \
printf "\r[TEST] docker-compose exec php php /shared/httpd/$(PROJECTV)/htdocs/$(file)\n"; \
cd $(DEVILBOX_PATH) && docker-composeexec php php /shared/httpd/$(PROJECTV)/htdocs/$(file); \
cd $(CURRENT_PATH) && $(MAKE) _logs; \
exit 1; \
else \
printf "\r[OK] docker-compose exec php php /shared/httpd/$(PROJECT)/htdocs/$(file)\n"; \
printf "\r[OK] docker-compose exec php php /shared/httpd/$(PROJECTV)/htdocs/$(file)\n"; \
fi; \
)
@echo
test-rhost:
@echo "####################################################################################################"
@echo "# RUNNING TESTS: RHOST"
@echo "####################################################################################################"
@echo
@# Gather files to test
$(eval SH_FILES := $(notdir $(wildcard $(CURRENT_PATH)/vhost-tests/$(PROJECTR)/tests/*.sh)))
@echo "# ----------------------------------------------------------------------------------------"
@echo "# [rhost] Startup"
@echo "# ----------------------------------------------------------------------------------------"
@$(CURRENT_PATH)/vhost-tests/$(PROJECTR)/start-pm.sh
@$(foreach file,\
$(SH_FILES), \
echo; \
echo "# ----------------------------------------------------------------------------------------"; \
echo "# [rhost] $(file)"; \
echo "# ----------------------------------------------------------------------------------------"; \
cd $(CURRENT_PATH) && $(MAKE) _clean-round >/dev/null; \
if ! $(CURRENT_PATH)/vhost-tests/$(PROJECTR)/tests/$(file); then \
cd $(CURRENT_PATH) && $(MAKE) _logs; \
exit 1; \
fi \
)
@echo
test-intra:
@echo "####################################################################################################"
@echo "# RUNNING TESTS: INTRANET"
@echo "####################################################################################################"
@echo
@# Gather files to test
$(eval SH_FILES := $(notdir $(wildcard $(CURRENT_PATH)/intra-tests/*.sh)))
@$(foreach file,\
$(SH_FILES), \
echo "# ----------------------------------------------------------------------------------------"; \
echo "# [intra] $(file)"; \
echo "# ----------------------------------------------------------------------------------------"; \
cd $(CURRENT_PATH) && $(MAKE) _clean-round >/dev/null; \
if ! $(CURRENT_PATH)/intra-tests/$(file); then \
cd $(CURRENT_PATH) && $(MAKE) _logs; \
exit 1; \
fi; \
echo; \
)
@echo
test-startup:
@echo "####################################################################################################"
@echo "# RUNNING TESTS: STARTUP"
@echo "####################################################################################################"
@echo
@if ! $(CURRENT_PATH)startup-tests/startup.sh; then \
@# Gather files to test
$(eval SH_FILES := $(notdir $(wildcard $(CURRENT_PATH)/startup-tests/*.sh)))
@$(foreach file,\
$(SH_FILES), \
cd $(CURRENT_PATH) && $(MAKE) _clean-round >/dev/null; \
if ! $(CURRENT_PATH)/startup-tests/$(file); then \
cd $(CURRENT_PATH) && $(MAKE) _logs; \
exit 1; \
fi
fi; \
echo; \
)
@echo
# -------------------------------------------------------------------------------------------------
@ -310,10 +360,10 @@ _clean-round:
@#cd $(DEVILBOX_PATH) && docker-compose exec httpd dd if=/dev/null of=/var/log/$(HTTPD_SERVER)/defaultlocalhost_ssl-access.log >/dev/null 2>&1 || true
@#cd $(DEVILBOX_PATH) && docker-compose exec httpd dd if=/dev/null of=/var/log/$(HTTPD_SERVER)/defaultlocalhost_ssl-error.log >/dev/null 2>&1 || true
@#cd $(DEVILBOX_PATH) && docker-compose exec httpd dd if=/dev/null of=/var/log/$(HTTPD_SERVER)/$(PROJECT)-access.log >/dev/null 2>&1 || true
@#cd $(DEVILBOX_PATH) && docker-compose exec httpd dd if=/dev/null of=/var/log/$(HTTPD_SERVER)/$(PROJECT)-error.log >/dev/null 2>&1 || true
@#cd $(DEVILBOX_PATH) && docker-compose exec httpd dd if=/dev/null of=/var/log/$(HTTPD_SERVER)/$(PROJECT)_ssl-access.log >/dev/null 2>&1 || true
@#cd $(DEVILBOX_PATH) && docker-compose exec httpd dd if=/dev/null of=/var/log/$(HTTPD_SERVER)/$(PROJECT)_ssl-error.log >/dev/null 2>&1 || true
@#cd $(DEVILBOX_PATH) && docker-compose exec httpd dd if=/dev/null of=/var/log/$(HTTPD_SERVER)/$(PROJECTV)-access.log >/dev/null 2>&1 || true
@#cd $(DEVILBOX_PATH) && docker-compose exec httpd dd if=/dev/null of=/var/log/$(HTTPD_SERVER)/$(PROJECTV)-error.log >/dev/null 2>&1 || true
@#cd $(DEVILBOX_PATH) && docker-compose exec httpd dd if=/dev/null of=/var/log/$(HTTPD_SERVER)/$(PROJECTV)_ssl-access.log >/dev/null 2>&1 || true
@#cd $(DEVILBOX_PATH) && docker-compose exec httpd dd if=/dev/null of=/var/log/$(HTTPD_SERVER)/$(PROJECTV)_ssl-error.log >/dev/null 2>&1 || true
_logs:
@ -415,27 +465,51 @@ _logs:
@echo
@echo "# ----------------------------------------------------------------------------------------"
@echo "# [HTTPD] $(PROJECT)-access.log"
@echo "# [HTTPD] $(PROJECTV)-access.log"
@echo "# ----------------------------------------------------------------------------------------"
cd $(DEVILBOX_PATH) && docker-compose exec httpd cat /var/log/$(HTTPD_SERVER)/$(PROJECT)-access.log || true
cd $(DEVILBOX_PATH) && docker-compose exec httpd cat /var/log/$(HTTPD_SERVER)/$(PROJECTV)-access.log || true
@echo
@echo "# ----------------------------------------------------------------------------------------"
@echo "# [HTTPD] $(PROJECT)-error.log"
@echo "# [HTTPD] $(PROJECTV)-error.log"
@echo "# ----------------------------------------------------------------------------------------"
cd $(DEVILBOX_PATH) && docker-compose exec httpd cat /var/log/$(HTTPD_SERVER)/$(PROJECT)-error.log || true
cd $(DEVILBOX_PATH) && docker-compose exec httpd cat /var/log/$(HTTPD_SERVER)/$(PROJECTV)-error.log || true
@echo
@echo "# ----------------------------------------------------------------------------------------"
@echo "# [HTTPD] $(PROJECT)_ssl-access.log"
@echo "# [HTTPD] $(PROJECTV)_ssl-access.log"
@echo "# ----------------------------------------------------------------------------------------"
cd $(DEVILBOX_PATH) && docker-compose exec httpd cat /var/log/$(HTTPD_SERVER)/$(PROJECT)_ssl-access.log || true
cd $(DEVILBOX_PATH) && docker-compose exec httpd cat /var/log/$(HTTPD_SERVER)/$(PROJECTV)_ssl-access.log || true
@echo
@echo "# ----------------------------------------------------------------------------------------"
@echo "# [HTTPD] $(PROJECT)_ssl-error.log"
@echo "# [HTTPD] $(PROJECTV)_ssl-error.log"
@echo "# ----------------------------------------------------------------------------------------"
cd $(DEVILBOX_PATH) && docker-compose exec httpd cat /var/log/$(HTTPD_SERVER)/$(PROJECT)_ssl-error.log || true
cd $(DEVILBOX_PATH) && docker-compose exec httpd cat /var/log/$(HTTPD_SERVER)/$(PROJECTV)_ssl-error.log || true
@echo
@echo "# ----------------------------------------------------------------------------------------"
@echo "# [HTTPD] $(PROJECTR)-access.log"
@echo "# ----------------------------------------------------------------------------------------"
cd $(DEVILBOX_PATH) && docker-compose exec httpd cat /var/log/$(HTTPD_SERVER)/$(PROJECTR)-access.log || true
@echo
@echo "# ----------------------------------------------------------------------------------------"
@echo "# [HTTPD] $(PROJECTR)-error.log"
@echo "# ----------------------------------------------------------------------------------------"
cd $(DEVILBOX_PATH) && docker-compose exec httpd cat /var/log/$(HTTPD_SERVER)/$(PROJECTR)-error.log || true
@echo
@echo "# ----------------------------------------------------------------------------------------"
@echo "# [HTTPD] $(PROJECTR)_ssl-access.log"
@echo "# ----------------------------------------------------------------------------------------"
cd $(DEVILBOX_PATH) && docker-compose exec httpd cat /var/log/$(HTTPD_SERVER)/$(PROJECTR)_ssl-access.log || true
@echo
@echo "# ----------------------------------------------------------------------------------------"
@echo "# [HTTPD] $(PROJECTR)_ssl-error.log"
@echo "# ----------------------------------------------------------------------------------------"
cd $(DEVILBOX_PATH) && docker-compose exec httpd cat /var/log/$(HTTPD_SERVER)/$(PROJECTR)_ssl-error.log || true
@echo

View File

@ -11,7 +11,7 @@ set -o pipefail
#
VHOST="${1:-vhost-tests}"
VHOST="${1:-my-vhost}"
VHOST_GEN_URL="/info_vhostgen.php?name=${VHOST}"
VHOST_URL="/vhost.d/${VHOST}.conf"

View File

@ -16,15 +16,16 @@ cd "${COMPOSEPATH}" && docker-compose exec -T php bash -c "find /startup.2.d/*.s
echo "# ----------------------------------------------------------------------------------------"
echo "# [TEST] ${f}"
echo "# ----------------------------------------------------------------------------------------"
if ! docker exec -t ${CONTAINER} bash "${f}" "ACCEPT_EULA=1"; then
if ! docker exec -t ${CONTAINER} bash "${f}" | grep -q "No projects defined"; then
sleep 5
if ! docker exec -t ${CONTAINER} bash "${f}" "ACCEPT_EULA=1"; then
if ! docker exec -t ${CONTAINER} bash "${f}" | grep -q "No projects defined"; then
sleep 5
if ! docker exec -t ${CONTAINER} bash "${f}" "ACCEPT_EULA=1"; then
if ! docker exec -t ${CONTAINER} bash "${f}" | grep -q "No projects defined"; then
sleep 5
if ! docker exec -t ${CONTAINER} bash "${f}" "ACCEPT_EULA=1"; then
if ! docker exec -t ${CONTAINER} bash "${f}" | grep -q "No projects defined"; then
sleep 5
if ! docker exec -t ${CONTAINER} bash "${f}" "ACCEPT_EULA=1"; then
if ! docker exec -t ${CONTAINER} bash "${f}" | grep -q "No projects defined"; then
docker exec -t ${CONTAINER} bash "${f}" || true
echo "[FAIl] ${f}"
exit 1
fi
@ -33,6 +34,4 @@ cd "${COMPOSEPATH}" && docker-compose exec -T php bash -c "find /startup.2.d/*.s
fi
fi
echo "[OK] ${f}"
echo
echo
done

View File

@ -1,161 +0,0 @@
---
# 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]

View File

@ -1,183 +0,0 @@
---
# 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]

View File

@ -1,157 +0,0 @@
---
# 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;
}

View File

@ -0,0 +1 @@
js

View File

@ -0,0 +1,11 @@
// Load the http module to create an http server.
var http = require('http');
// Configure our HTTP server to respond with Hello World to all requests.
var server = http.createServer(function (request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.end("Hello World\n");
});
// Listen on port 8000, IP defaults to 127.0.0.1
server.listen(8000);

View File

@ -0,0 +1,30 @@
#!/usr/bin/env bash
set -e
set -u
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
COMPOSEPATH="${SCRIPTPATH}/../../../"
NODE_PATH="/shared/httpd/my-rhost/js"
NODE_FILE="index.js"
if ! cd "${COMPOSEPATH}" && docker-compose exec php test -d "${NODE_PATH}"; then
>&2 echo "[Warning], skipping startup, directory does not exist in container: ${NODE_PATH}"
exit 1
fi
if ! cd "${COMPOSEPATH}" && docker-compose exec php test -f "${NODE_PATH}/${NODE_FILE}"; then
>&2 echo "[Warning], skipping startup, file does not exist in container: ${NODE_PATH}/${NODE_FILE}"
exit 1
fi
# Check if at least one pm2 process is already running
if cd "${COMPOSEPATH}" && docker-compose exec --user devilbox php bash -c "cd /shared/httpd/my-rhost/js; pm2 show 0 >/dev/null"; then
>&2 echo "[Warning], pm2 process already running"
else
echo "su -c \"cd ${NODE_PATH}; pm2 start ${NODE_FILE}\" -l devilbox"
cd "${COMPOSEPATH}" && docker-compose exec --user devilbox php bash -c "cd /shared/httpd/my-rhost/js; pm2 start ${NODE_FILE}"
fi

View File

@ -0,0 +1,30 @@
#!/usr/bin/env bash
set -e
set -u
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
COMPOSEPATH="${SCRIPTPATH}/../../../../"
printf "[TEST] http://my-rhost.loc"
# 1st round
if ! cd "${COMPOSEPATH}" && docker-compose exec --user devilbox php curl http://my-rhost.loc | grep "Hellp World"; then
sleep 1;
# 2nd round
if ! cd "${COMPOSEPATH}" && docker-compose exec --user devilbox php curl http://my-rhost.loc | grep "Hellp World"; then
sleep 1;
# 3rd round
if ! cd "${COMPOSEPATH}" && docker-compose exec --user devilbox php curl http://my-rhost.loc | grep "Hellp World"; then
printf "\r[FAIL] http://my-rhost.loc\n"
cd "${COMPOSEPATH}" && docker-compose exec --user devilbox php curl http://my-rhost.loc
exit 1
else
printf "\r[OK] http://my-rhost.loc (3 rounds)\n"
fi
else
printf "\r[OK] http://my-rhost.loc (2 rounds)\n"
fi
else
printf "\r[OK] http://my-rhost.loc (1 round)\n"
fi