This commit is contained in:
Yann Autissier
2022-12-22 02:57:43 +00:00
parent 2dec68807e
commit 94a749e229
27 changed files with 2182 additions and 29 deletions
+32
View File
@@ -0,0 +1,32 @@
FROM nimmis/alpine-apache-php5
ARG DOCKER_BUILD_DIR
RUN apk add --no-cache \
memcached \
php5-bz2 \
php5-enchant \
php5-gmp \
php5-imap \
php5-ldap \
php5-memcache \
php5-mssql \
php5-mysqli \
php5-opcache \
php5-pdo \
php5-pdo_mysql \
php5-pdo_pgsql \
php5-pdo_sqlite \
php5-pspell \
php5-snmp \
php5-xcache \
php5-xmlrpc \
php5-xsl
COPY ${DOCKER_BUILD_DIR}/apache-php5-config.sh /etc/run_always/51-config-apache
COPY ${DOCKER_BUILD_DIR}/php.ini /etc/php5/
COPY ${DOCKER_BUILD_DIR}/header.php /etc/php5/
RUN mkdir -p /etc/sv/memcached \
&& echo -e '#!/bin/sh\n\nexec 2>&1\nexec chpst -u apache /usr/bin/memcached -s /var/tmp/memcached\n' > /etc/sv/memcached/run \
&& chmod +x /etc/sv/memcached/run \
&& ln -s ../sv/memcached /etc/service/memcached
+22
View File
@@ -0,0 +1,22 @@
#!/bin/sh
set -eu
DOCUMENT_ROOT=${DOCUMENT_ROOT:-/web/html}
LOAD_MODULE=${LOAD_MODULE:-env expires headers remoteip reqtimeout rewrite setenvif slotmem_shm vhost_alias}
PREFIX=${PREFIX:-/web/config}
SERVER_NAME=${SERVER_NAME:-$(hostname)}
VIRTUAL_ROOT=${VIRTUAL_ROOT:-%0}
sed -E -i \
-e 's!^#?\s*(LoadModule ('${LOAD_MODULE// /|}')_module modules/mod_('${LOAD_MODULE// /|}').so)\s*!\1!g' \
-e 's!^ServerName .*!ServerName '${SERVER_NAME}'!g' \
-e 's!^ServerSignature .*!ServerSignature Off!g' \
-e 's!DocumentRoot .*!DocumentRoot "'${DOCUMENT_ROOT}'"!; /DocumentRoot/,/Directory/{s!Directory .*"!Directory "'${DOCUMENT_ROOT}'"!}' \
"$PREFIX/httpd.conf"
sed -ni \
-e '/^VirtualDocumentRoot/!p;$a VirtualDocumentRoot '"${DOCUMENT_ROOT}/${VIRTUAL_ROOT:-%-1/%-2/%-3}"'' \
"$PREFIX/conf.d/default.conf"
sed -i \
-e 's!internal!localhost!g' \
-e 's!^Alias .*!Alias "/localhost" "'${DOCUMENT_ROOT}'/localhost"!g; /Alias/,/Directory/{s!Directory .*"!Directory "'${DOCUMENT_ROOT}/localhost'"!}' \
"$PREFIX/conf.d/errordocs.conf"
+33
View File
@@ -0,0 +1,33 @@
<?php
if( PHP_SAPI != 'cli' ) {
if( $_SERVER["HTTP_X_FORWARDED_PROTO"] == 'https' )
$_SERVER["SERVER_PORT"] = 443;
else
$_SERVER["SERVER_PORT"] = 80;
}
function error_handler() {
$error = error_get_last();
if ($error) switch ($error['type']) {
case E_ERROR: // 1
readfile("/var/www/html/500.html");
break;
case E_PARSE: // 4
case E_CORE_ERROR: // 16
case E_CORE_WARNING: // 32
case E_COMPILE_ERROR: // 64
case E_COMPILE_WARNING: // 128
case E_USER_ERROR: // 256
case E_RECOVERABLE_ERROR: // 4096
readfile("/var/www/html/50x.html");
break;
case E_WARNING: // 2
case E_NOTICE: // 8
case E_USER_WARNING: // 512
case E_USER_NOTICE: // 1024
case E_STRICT: // 2048
case E_DEPRECATED: // 8192
case E_USER_DEPRECATED: // 16384
}
}
register_shutdown_function('error_handler');
?>
File diff suppressed because it is too large Load Diff
+4 -1
View File
@@ -2,7 +2,10 @@ FROM pinidh/nginx-proxy:alpine
ARG DOCKER_BUILD_DIR
RUN sed -i 's/\(function _resolvers() {\)$/function _nginx_config() {\n\t\/app\/nginx-config.sh\n}\n\n\1/;s/\(\t_default_certificate\)$/\1\n\n\t_nginx_config/' /app/docker-entrypoint.sh \
&& sed -i 's|\(\treturn 503;\)$|\t{{ if (exists (printf "/etc/nginx/vhost.d/default")) }}\n\tinclude {{ printf "/etc/nginx/vhost.d/default" }};\n\t {{ if (exists (printf "/etc/nginx/vhost.d/default_location")) }}\n\tinclude {{ printf "/etc/nginx/vhost.d/default_location" }};\n\t {{ end }}\n\t{{ else }}\n\1\n\t{{ end }}|' /app/nginx.tmpl \
&& sed -i 's|\(\treturn 503;\)$|\t{{ if (exists (printf "/etc/nginx/vhost.d/%s" (or $.Env.DEFAULT "default"))) }}\n\tinclude {{ printf "/etc/nginx/vhost.d/%s" (or $.Env.DEFAULT "default") }};\n\t {{ if (exists (printf "/etc/nginx/vhost.d/default_location")) }}\n{{ if $.Env.DEFAULT_LOCATION }}\tinclude {{ printf "/etc/nginx/vhost.d/default_location" }};{{ end }}\n\t {{ if (exists (printf "/etc/nginx/vhost.d/default_location_php")) }}\n{{ if $.Env.DEFAULT_LOCATION_PHP }}\tinclude {{ printf "/etc/nginx/vhost.d/default_location_php" }};{{ end }}\n\t {{ end }}\n\t {{ if (exists (printf "/etc/nginx/vhost.d/default_location_ipfs")) }}\n{{ if $.Env.DEFAULT_LOCATION_IPFS }}\tinclude {{ printf "/etc/nginx/vhost.d/default_location_ipfs" }};{{ end }}\n\t {{ end }}\n\t {{ end }}\n\t{{ else }}\n\1\n\t{{ end }}|' /app/nginx.tmpl \
&& sed -i 's|\({{ if (exists "/etc/nginx/proxy.conf") }}\)|{{ if (exists "/etc/nginx/vhost.d/nginx.conf") }}\ninclude /etc/nginx/vhost.d/nginx.conf;\n{{ end }}\n\n\1|' /app/nginx.tmpl \
&& sed -i 's|exists "/etc/nginx/vhost.d/default"|exists (printf "/etc/nginx/vhost.d/%s" (or $.Env.DEFAULT "default"))|;s|include /etc/nginx/vhost.d/default;|include {{ printf "/etc/nginx/vhost.d/%s" (or $.Env.DEFAULT "default") }};|' /app/nginx.tmpl \
&& sed -i 's|\(include /etc/nginx/vhost.d/default_location;\)|\1\n\t\t{{ if (exists (printf "/etc/nginx/vhost.d/default_location_php")) }}\n{{ if $.Env.DEFAULT_LOCATION_PHP }}\tinclude {{ printf "/etc/nginx/vhost.d/default_location_php" }};{{ end }}\n\t\t{{ end }}\n\t\t{{ if (exists (printf "/etc/nginx/vhost.d/default_location_ipfs")) }}\n{{ if $.Env.DEFAULT_LOCATION_IPFS }}\tinclude {{ printf "/etc/nginx/vhost.d/default_location_ipfs" }};{{ end }}\n\t\t{{ end }}|' /app/nginx.tmpl \
&& awk '/proxy_pass \{\{ trim .Proto \}\}/{sub(/else/, "else if ne .Proto \"local\"", last)} NR>1{print last} {last=$0} END {print last}' /app/nginx.tmpl > /tmp/nginx.tmpl && mv /tmp/nginx.tmpl /app/
COPY ${DOCKER_BUILD_DIR}/nginx* /app
+4
View File
@@ -12,4 +12,8 @@ sed -i 's/fastcgi_param * SERVER_SOFTWARE *.*/fastcgi_param SERVER_SOFTWARE
mkdir -p /etc/nginx/htpasswd /etc/nginx/vhost.d
[ -f "/etc/nginx/htpasswd/default" ] || echo "default:{PLAIN}$(head -c 15 /dev/random |base64)" > /etc/nginx/htpasswd/default
[ -f "/etc/nginx/vhost.d/default" ] || cp /app/nginx_default /etc/nginx/vhost.d/default
[ -f "/etc/nginx/vhost.d/default_dns" ] || cp /app/nginx_default_dns /etc/nginx/vhost.d/default_dns
[ -f "/etc/nginx/vhost.d/default_location" ] || cp /app/nginx_default_location /etc/nginx/vhost.d/default_location
[ -f "/etc/nginx/vhost.d/default_location_php" ] || cp /app/nginx_default_location_php /etc/nginx/vhost.d/default_location_php
[ -f "/etc/nginx/vhost.d/default_location_ipfs" ] || cp /app/nginx_default_location_ipfs /etc/nginx/vhost.d/default_location_ipfs
[ -f "/etc/nginx/vhost.d/nginx.conf" ] || cp /app/nginx.conf /etc/nginx/vhost.d/nginx.conf
+9
View File
@@ -0,0 +1,9 @@
map $host $host_dir {
hostnames;
~(?:(?<sssssd>[a-z0-9-]+)\.)(?:(?<ssssd>[a-z0-9-]+)\.)(?:(?<sssd>[a-z0-9-]+)\.)(?:(?<ssd>[a-z0-9-]+)\.)(?:(?<sd>[a-z0-9-]+)\.)(?<dom>[a-z0-9-]+)\.(?<tld>[a-z0-9-]+)$ ${tld}/${dom}/${sd}/${ssd}/${sssd}/${ssssd}/${sssssd};
~(?:(?<ssssd>[a-z0-9-]+)\.)(?:(?<sssd>[a-z0-9-]+)\.)(?:(?<ssd>[a-z0-9-]+)\.)(?:(?<sd>[a-z0-9-]+)\.)(?<dom>[a-z0-9-]+)\.(?<tld>[a-z0-9-]+)$ ${tld}/${dom}/${sd}/${ssd}/${sssd}/${ssssd};
~(?:(?<sssd>[a-z0-9-]+)\.)(?:(?<ssd>[a-z0-9-]+)\.)(?:(?<sd>[a-z0-9-]+)\.)(?<dom>[a-z0-9-]+)\.(?<tld>[a-z0-9-]+)$ ${tld}/${dom}/${sd}/${ssd}/${sssd};
~(?:(?<ssd>[a-z0-9-]+)\.)(?:(?<sd>[a-z0-9-]+)\.)(?<dom>[a-z0-9-]+)\.(?<tld>[a-z0-9-]+)$ ${tld}/${dom}/${sd}/${ssd};
~(?:(?<sd>[a-z0-9-]+)\.)(?<dom>[a-z0-9-]+)\.(?<tld>[a-z0-9-]+)$ ${tld}/${dom}/${sd};
~(?<dom>[a-z0-9-]+)\.(?<tld>[a-z0-9-]+)$ ${tld}/${dom};
}
+1
View File
@@ -0,0 +1 @@
root /dns/$host_dir;
+19 -2
View File
@@ -1,6 +1,23 @@
error_page 403 /localhost/403.html;
error_page 404 /localhost/404.html;
error_page 500 /localhost/500.html;
error_page 502 503 504 /localhost/50x.html;
index index.php index.html index.htm;
try_files $uri $uri/ index.php$uri =404;
try_files $uri $uri/ =404;
location ~ /\.ht {
location /localhost/ {
alias /usr/share/nginx/html/;
}
location ^~ /.well-known/acme-challenge/ {
auth_basic off;
auth_request off;
allow all;
root /usr/share/nginx/html;
try_files $uri =404;
break;
}
location ~ /\. {
deny all;
}
+3
View File
@@ -0,0 +1,3 @@
location ~ /ip(f|n)s {
proxy_pass http://$host:8080;
}
+10
View File
@@ -0,0 +1,10 @@
location ~ ^(.+\.php)(.*)$ {
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass php;
fastcgi_split_path_info ^(.+\.php)(.*)$;
include fastcgi_params;
try_files $uri index.php$uri =404;
}
fastcgi_intercept_errors on;