diff --git a/bitnami/nginx/1.27/debian-12/Dockerfile b/bitnami/nginx/1.27/debian-12/Dockerfile index 327048fe6bba..699058e9f520 100644 --- a/bitnami/nginx/1.27/debian-12/Dockerfile +++ b/bitnami/nginx/1.27/debian-12/Dockerfile @@ -7,11 +7,11 @@ ARG TARGETARCH LABEL com.vmware.cp.artifact.flavor="sha256:c50c90cfd9d12b445b011e6ad529f1ad3daea45c26d20b00732fae3cd71f6a83" \ org.opencontainers.image.base.name="docker.io/bitnami/minideb:bookworm" \ - org.opencontainers.image.created="2024-09-10T06:26:46Z" \ + org.opencontainers.image.created="2024-09-13T07:00:10Z" \ org.opencontainers.image.description="Application packaged by Broadcom, Inc." \ org.opencontainers.image.documentation="https://github.com/bitnami/containers/tree/main/bitnami/nginx/README.md" \ org.opencontainers.image.licenses="Apache-2.0" \ - org.opencontainers.image.ref.name="1.27.1-debian-12-r4" \ + org.opencontainers.image.ref.name="1.27.1-debian-12-r5" \ org.opencontainers.image.source="https://github.com/bitnami/containers/tree/main/bitnami/nginx" \ org.opencontainers.image.title="nginx" \ org.opencontainers.image.vendor="Broadcom, Inc." \ diff --git a/bitnami/nginx/1.27/debian-12/rootfs/opt/bitnami/scripts/libnginx.sh b/bitnami/nginx/1.27/debian-12/rootfs/opt/bitnami/scripts/libnginx.sh index 84b872d13fb8..30902934f122 100644 --- a/bitnami/nginx/1.27/debian-12/rootfs/opt/bitnami/scripts/libnginx.sh +++ b/bitnami/nginx/1.27/debian-12/rootfs/opt/bitnami/scripts/libnginx.sh @@ -208,9 +208,14 @@ 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" )" + # Stream configuration + if is_boolean_yes "$NGINX_ENABLE_STREAM" && is_file_writable "$NGINX_CONF_FILE"; then + cat >> "$NGINX_CONF_FILE" <> "$NGINX_CONF_FILE" +stream { + include "${NGINX_STREAM_SERVER_BLOCKS_DIR}/*.conf"; +} +EOF fi } diff --git a/bitnami/nginx/1.27/debian-12/rootfs/opt/bitnami/scripts/nginx-env.sh b/bitnami/nginx/1.27/debian-12/rootfs/opt/bitnami/scripts/nginx-env.sh index 0a02d51a104c..707a05dbe6db 100644 --- a/bitnami/nginx/1.27/debian-12/rootfs/opt/bitnami/scripts/nginx-env.sh +++ b/bitnami/nginx/1.27/debian-12/rootfs/opt/bitnami/scripts/nginx-env.sh @@ -27,9 +27,9 @@ nginx_env_vars=( NGINX_HTTP_PORT_NUMBER NGINX_HTTPS_PORT_NUMBER NGINX_SKIP_SAMPLE_CERTS + NGINX_ENABLE_STREAM 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" @@ -77,8 +77,8 @@ export WEB_SERVER_HTTP_PORT_NUMBER="$NGINX_HTTP_PORT_NUMBER" export NGINX_HTTPS_PORT_NUMBER="${NGINX_HTTPS_PORT_NUMBER:-}" export WEB_SERVER_HTTPS_PORT_NUMBER="$NGINX_HTTPS_PORT_NUMBER" export NGINX_SKIP_SAMPLE_CERTS="${NGINX_SKIP_SAMPLE_CERTS:-false}" +export NGINX_ENABLE_STREAM="${NGINX_ENABLE_STREAM:-no}" 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 diff --git a/bitnami/nginx/1.27/debian-12/rootfs/opt/bitnami/scripts/nginx/bitnami-templates/default-stream-block.conf b/bitnami/nginx/1.27/debian-12/rootfs/opt/bitnami/scripts/nginx/bitnami-templates/default-stream-block.conf deleted file mode 100644 index 02f84916bad8..000000000000 --- a/bitnami/nginx/1.27/debian-12/rootfs/opt/bitnami/scripts/nginx/bitnami-templates/default-stream-block.conf +++ /dev/null @@ -1,4 +0,0 @@ -# stream block -stream { - include "/opt/bitnami/nginx/conf/stream_server_blocks/*.conf"; -} diff --git a/bitnami/nginx/README.md b/bitnami/nginx/README.md index c6607b28fae1..b5e9f05874c5 100644 --- a/bitnami/nginx/README.md +++ b/bitnami/nginx/README.md @@ -117,7 +117,6 @@ 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`: @@ -132,7 +131,7 @@ server { } ``` -## Step 2: Mount the configuration as a volume +## Step 2: Mount the server block as a volume ```console docker run --name nginx \ @@ -151,6 +150,52 @@ services: ... ``` +### Adding custom stream server blocks + +Similar to server blocks, you can include server blocks for the [NGINX Stream Core Module](https://nginx.org/en/docs/stream/ngx_stream_core_module.html) mounting them at `/opt/bitnami/nginx/conf/stream_server_blocks/`. In order to do so, it's also necessary to set the `NGINX_ENABLE_STREAM` environment variable to `yes`. + +## Step 1: Write your `my_stream_server_block.conf` file with the following content + +```nginx +upstream backend { + hash $remote_addr consistent; + + server backend1.example.com:12345 weight=5; + server 127.0.0.1:12345 max_fails=3 fail_timeout=30s; + server unix:/tmp/backend3; +} + +server { + listen 12345; + proxy_connect_timeout 1s; + proxy_timeout 3s; + proxy_pass backend; +} +``` + +## Step 2: Mount the stream server block as a volume + +```console +docker run --name nginx \ + -e NGINX_ENABLE_STREAM=yes \ + -v /path/to/my_stream_server_block.conf:/opt/bitnami/nginx/conf/stream_server_blocks/my_stream_server_block.conf:ro \ + bitnami/nginx:latest +``` + +or by modifying the [`docker-compose.yml`](https://github.com/bitnami/containers/blob/main/bitnami/nginx/docker-compose.yml) file present in this repository: + +```yaml +services: + nginx: + ... + environment: + - NGINX_ENABLE_STREAM=yes + ... + volumes: + - /path/to/my_stream_server_block.conf:/opt/bitnami/nginx/conf/stream_server_blocks/my_stream_server_block.conf:ro + ... +``` + ### Using custom SSL certificates *NOTE:* The steps below assume that you are using a custom domain name and that you have already configured the custom domain name to point to your server.