[bitnami/nginx] stream server blocks (#72353)

This commit is contained in:
TrueGameover
2024-09-13 13:57:23 +07:00
committed by GitHub
parent 365e902a30
commit 360511e1e2
5 changed files with 13 additions and 1 deletions

View File

@@ -208,6 +208,10 @@ nginx_initialize() {
fi
nginx_configure "absolute_redirect" "$(is_boolean_yes "$NGINX_ENABLE_ABSOLUTE_REDIRECT" && echo "on" || echo "off" )"
nginx_configure "port_in_redirect" "$(is_boolean_yes "$NGINX_ENABLE_PORT_IN_REDIRECT" && echo "on" || echo "off" )"
if is_boolean_yes "$NGINX_ENABLE_STREAM"; then
is_file_writable "$NGINX_CONF_FILE" && cat "${BITNAMI_ROOT_DIR}/scripts/nginx/bitnami-templates/default-stream-block.conf" >> "$NGINX_CONF_FILE"
fi
}
########################

View File

@@ -29,6 +29,7 @@ nginx_env_vars=(
NGINX_SKIP_SAMPLE_CERTS
NGINX_ENABLE_ABSOLUTE_REDIRECT
NGINX_ENABLE_PORT_IN_REDIRECT
NGINX_ENABLE_STREAM
)
for env_var in "${nginx_env_vars[@]}"; do
file_env_var="${env_var}_FILE"
@@ -54,6 +55,7 @@ export NGINX_HTDOCS_DIR="${NGINX_BASE_DIR}/html"
export NGINX_TMP_DIR="${NGINX_BASE_DIR}/tmp"
export NGINX_LOGS_DIR="${NGINX_BASE_DIR}/logs"
export NGINX_SERVER_BLOCKS_DIR="${NGINX_CONF_DIR}/server_blocks"
export NGINX_STREAM_SERVER_BLOCKS_DIR="${NGINX_CONF_DIR}/stream_server_blocks"
export NGINX_INITSCRIPTS_DIR="/docker-entrypoint-initdb.d"
export NGINX_CONF_FILE="${NGINX_CONF_DIR}/nginx.conf"
export NGINX_PID_FILE="${NGINX_TMP_DIR}/nginx.pid"
@@ -77,5 +79,6 @@ export WEB_SERVER_HTTPS_PORT_NUMBER="$NGINX_HTTPS_PORT_NUMBER"
export NGINX_SKIP_SAMPLE_CERTS="${NGINX_SKIP_SAMPLE_CERTS:-false}"
export NGINX_ENABLE_ABSOLUTE_REDIRECT="${NGINX_ENABLE_ABSOLUTE_REDIRECT:-no}"
export NGINX_ENABLE_PORT_IN_REDIRECT="${NGINX_ENABLE_PORT_IN_REDIRECT:-no}"
export NGINX_ENABLE_STREAM="${NGINX_ENABLE_STREAM:-no}"
# Custom environment variables may be defined below

View File

@@ -0,0 +1,4 @@
# stream block
stream {
include "/opt/bitnami/nginx/conf/stream_server_blocks/*.conf";
}

View File

@@ -39,7 +39,7 @@ rm -rf "${BITNAMI_ROOT_DIR}/certs" "${BITNAMI_ROOT_DIR}/server_blocks"
# Ensure non-root user has write permissions on a set of directories
chmod g+w "$NGINX_BASE_DIR"
for dir in "$NGINX_VOLUME_DIR" "$NGINX_CONF_DIR" "$NGINX_INITSCRIPTS_DIR" "$NGINX_SERVER_BLOCKS_DIR" "${NGINX_CONF_DIR}/bitnami" "${NGINX_CONF_DIR}/bitnami/certs" "$NGINX_LOGS_DIR" "$NGINX_TMP_DIR" "$NGINX_DEFAULT_CONF_DIR"; do
for dir in "$NGINX_VOLUME_DIR" "$NGINX_CONF_DIR" "$NGINX_INITSCRIPTS_DIR" "$NGINX_SERVER_BLOCKS_DIR" "$NGINX_STREAM_SERVER_BLOCKS_DIR" "${NGINX_CONF_DIR}/bitnami" "${NGINX_CONF_DIR}/bitnami/certs" "$NGINX_LOGS_DIR" "$NGINX_TMP_DIR" "$NGINX_DEFAULT_CONF_DIR"; do
ensure_dir_exists "$dir"
chmod -R g+rwX "$dir"
done

View File

@@ -117,6 +117,7 @@ Access your web server in the browser by navigating to `http://localhost:9000`.
### Adding custom server blocks
The default `nginx.conf` includes server blocks placed in `/opt/bitnami/nginx/conf/server_blocks/`. You can mount a `my_server_block.conf` file containing your custom server block at this location.
Also `/opt/bitnami/nginx/conf/stream_server_blocks/` available for stream server blocks which can be enabled via NGINX_ENABLE_STREAM.
For example, in order add a server block for `www.example.com`: