add nginx proxy

This commit is contained in:
Yann Autissier
2022-12-10 17:58:25 +00:00
parent 92dcf23fdd
commit 1d1b5156bc
52 changed files with 442 additions and 173 deletions
+24
View File
@@ -0,0 +1,24 @@
FROM httpd:alpine as dist
LABEL maintainer aynic.os <support+docker@asycn.io>
ARG DOCKER_BUILD_DIR
ARG HTTPD_LOAD_MODULE="env expires headers lbmethod_bybusyness lbmethod_byrequests proxy proxy_balancer proxy_fcgi proxy_http setenvif slotmem_shm reqtimeout rewrite"
ARG HTTPD_CONF_EXTRA="default info mpm vhosts"
RUN sed -E -i \
-e 's!^#?\s*(LoadModule ('${HTTPD_LOAD_MODULE// /|}')_module modules/mod_('${HTTPD_LOAD_MODULE// /|}').so)\s*!\1!g' \
-e 's!^#?\s*(Include conf/extra/httpd-('${HTTPD_CONF_EXTRA// /|}').conf)\s*!\1!g' \
"$HTTPD_PREFIX/conf/httpd.conf";
COPY ${DOCKER_BUILD_DIR}/docker-entrypoint.sh /
COPY ${DOCKER_BUILD_DIR}/httpd-vhosts.ctmpl /usr/local/apache2/conf/extra/
COPY --from=hashicorp/consul-template:alpine /bin/consul-template /usr/local/bin/
WORKDIR /var/www
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD /usr/local/bin/consul-template -log-level info -consul-addr consul:8500 -template "/usr/local/apache2/conf/extra/httpd-vhosts.ctmpl:/usr/local/apache2/conf/extra/httpd-vhosts.conf" -exec "/usr/local/bin/httpd-foreground"
EXPOSE 80/tcp
FROM dist as master
ARG DOCKER_BUILD_DIR
+9
View File
@@ -0,0 +1,9 @@
#!/bin/sh
set -euo pipefail
set -o errexit
trap 'kill -SIGQUIT $PID' INT
# Launch httpd
[ $# -eq 0 ] && httpd-foreground || exec "$@" &
PID=$! && wait
+21
View File
@@ -0,0 +1,21 @@
{{ $serverName := printf "%s.%s.%s" (env "ENV") (env "APP") (env "USER") }}
{{ $serviceName := printf "%s-%s-%s-php-9000" (env "USER") (env "APP") (env "ENV") }}
<VirtualHost *:80>
ServerAdmin support+apache@asycn.io
DocumentRoot "/var/www/web"
ServerName {{ $serverName }}
ServerAlias *
<FilesMatch "\.php$">
SetHandler "proxy:balancer://php/"
</FilesMatch>
<Proxy "balancer://php/">
{{ range service $serviceName }} BalancerMember "fcgi://{{ .Address }}:{{ .Port }}/" disablereuse=On timeout=900
{{ end }} ProxySet lbmethod=bybusyness
</Proxy>
<Directory /var/www/web>
AllowOverride All
CGIPassAuth On
Options +FollowSymLinks
Require all granted
</Directory>
</VirtualHost>