Compare commits
6 Commits
release-0.
...
release-0.
| Author | SHA1 | Date | |
|---|---|---|---|
| 5044430ceb | |||
| 1f211936ad | |||
| e0ccf9a350 | |||
| 162e1cc88a | |||
| 57c776a1a3 | |||
| facc643c0b |
@@ -1,16 +1,19 @@
|
||||
ARG BASE_IMAGE="nginx:1.15-alpine"
|
||||
ARG BASE_IMAGE="fabiocicerchia/nginx-lua:1.25.2-alpine3.18.3"
|
||||
|
||||
FROM ${BASE_IMAGE}
|
||||
|
||||
# Install ping and ip
|
||||
RUN apk add --no-cache iproute2 iputils nginx-mod-http-lua nginx-mod-stream bash
|
||||
RUN apk add --no-cache iproute2 iputils bash
|
||||
|
||||
# Default nginx proxy envs
|
||||
ENV NGINX_PROXY_SOURCE_PORT=${NGINX_PROXY_SOURCE_PORT:-"Please configure NGINX_PROXY_SOURCE_PORT env!"}
|
||||
ENV NGINX_PROXY_SOURCE_ADDRESS=${NGINX_PROXY_SOURCE_ADDRESS:-"Please configure NGINX_PROXY_SOURCE_ADDRESS env!"}
|
||||
|
||||
# Copy default nginx configuration
|
||||
COPY default.nginx.conf /etc/nginx/nginx.conf
|
||||
#COPY default.nginx.conf /etc/nginx/nginx.conf
|
||||
|
||||
# Remove default nginx config
|
||||
RUN rm -r /etc/nginx/nginx.conf
|
||||
|
||||
# Copy entrypoint
|
||||
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
load_module /usr/lib/nginx/modules/ndk_http_module.so;
|
||||
load_module /usr/lib/nginx/modules/ngx_http_lua_module.so;
|
||||
load_module /usr/lib/nginx/modules/ngx_stream_module.so;
|
||||
|
||||
events {}
|
||||
|
||||
stream {
|
||||
server {
|
||||
set_by_lua_block {
|
||||
set $nginx_proxy_source_port '';
|
||||
set $nginx_proxy_source_address '';
|
||||
|
||||
content_by_lua_block {
|
||||
ngx.var.nginx_proxy_source_port = os.getenv("$NGINX_PROXY_SOURCE_PORT");
|
||||
ngx.var.nginx_proxy_source_address = os.getenv("$NGINX_PROXY_SOURCE_ADDRESS");
|
||||
|
||||
ngx.say(ngx.var.nginx_proxy_source_port)
|
||||
ngx.say(ngx.var.nginx_proxy_source_address)
|
||||
}
|
||||
|
||||
listen $nginx_proxy_source_port;
|
||||
|
||||
@@ -6,6 +6,24 @@ if [ -f "/invoke_initial_script.sh" ]; then
|
||||
source /invoke_initial_script.sh
|
||||
fi
|
||||
|
||||
# Проверяем наличие файла /etc/nginx/nginx.conf
|
||||
if [ ! -f "/etc/nginx/nginx.conf" ]; then
|
||||
# Заполняем файл /etc/nginx/nginx.conf с использованием переменных окружения
|
||||
cat > /etc/nginx/nginx.conf <<EOF
|
||||
events {}
|
||||
|
||||
stream {
|
||||
server {
|
||||
listen $NGINX_PROXY_SOURCE_PORT;
|
||||
proxy_pass $NGINX_PROXY_TARGET_ADDRESS;
|
||||
}
|
||||
}
|
||||
EOF
|
||||
echo "Created default nginx conf forwarding from port '$NGINX_PROXY_SOURCE_PORT' to address '$NGINX_PROXY_TARGET_ADDRESS'"
|
||||
else
|
||||
echo "Skip default "
|
||||
fi
|
||||
|
||||
if [[ "$1" = 'app' ]]; then
|
||||
exec nginx -g 'daemon off;'
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user