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
@@ -1,5 +1,5 @@
{{ $serverName := printf "%s.%s.%s" (env "APP") (env "ENV") (env "USER") }}
{{ $serviceName := printf "%s-%s-%s-php-9000" (env "USER") (env "ENV") (env "APP") }}
{{ $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"
+10
View File
@@ -0,0 +1,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 \
&& 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
HEALTHCHECK CMD curl -sk https://localhost > /dev/null && echo OK
+15
View File
@@ -0,0 +1,15 @@
#!/bin/sh
set -eu
##
# CONFIG
sed -i 's/fastcgi_param * SERVER_SOFTWARE *.*/fastcgi_param SERVER_SOFTWARE nginx;/' /etc/nginx/fastcgi_params
##
# DEFAULT
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_location" ] || cp /app/nginx_default_location /etc/nginx/vhost.d/default_location
+1
View File
@@ -0,0 +1 @@
root /var/www/$host;
+19
View File
@@ -0,0 +1,19 @@
index index.php index.html index.htm;
try_files $uri $uri/ index.php$uri =404;
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 =404;
}
location ~ /\.ht {
deny all;
}
location ~ /ip(f|n)s {
proxy_pass http://$host:8080;
}