nginx
by Bitnami
NGINX Open Source is a web server that can be also used as a reverse proxy, load balancer, and HTTP cache. Recommended for high-demanding sites due to its ability to provide faster content.
About this chart
Bitnami Secure Images Helm chart for NGINX Open Source
NGINX Open Source is a web server that can be also used as a reverse proxy, load balancer, and HTTP cache. Recommended for high-demanding sites due to its ability to provide faster content.
Trademarks: This software listing is packaged by Bitnami. The respective trademarks mentioned in the offering are owned by the respective companies, and use of them does not imply any affiliation or endorsement.
TL;DR
helm install my-release oci://MY-OCI-REGISTRY/nginx
Why use Bitnami Secure Images?
Those are hardened, minimal CVE images built and maintained by Bitnami. Bitnami Secure Images are based on the cloud-optimized, security-hardened enterprise OS Photon Linux. Why choose BSI images?
- Hardened secure images of popular open source software with Near-Zero Vulnerabilities
- Vulnerability Triage & Prioritization with VEX Statements, KEV and EPSS Scores
- Compliance focus with FIPS, STIG, and air-gap options, including secure bill of materials (SBOM)
- Software supply chain provenance attestation through in-toto
- First class support for the internet’s favorite Helm charts
Each image comes with valuable security metadata. You can view the metadata in our public catalog here. Note: Some data is only available with commercial subscriptions to BSI.
If you are looking for our previous generation of images based on Debian Linux, please see the Bitnami Legacy registry.
Introduction
Bitnami charts for Helm are carefully engineered, actively maintained and are the quickest and easiest way to deploy containers on a Kubernetes cluster that are ready to handle production workloads.
This chart bootstraps a NGINX Open Source deployment on a Kubernetes cluster using the Helm package manager.
Before you begin
- Kubernetes 1.23+
- Helm 3.8.0+
Installing the Chart
First, log in to the OCI registry and create a secret with your registry credentials:
helm registry login REGISTRY_NAME
kubectl create secret docker-registry SECRET_NAME -n NAMESPACE \
--docker-server REGISTRY_NAME \
--docker-username "USER" \
--docker-password "TOKEN"
Note Replace the placeholders in these commands (
REGISTRY_NAME,SECRET_NAME,NAMESPACE,USER, andTOKEN) with your actual values.
Then install the chart with the release name my-release:
helm install my-release oci://REGISTRY_NAME/REPOSITORY_NAME/nginx --set "global.imagePullSecrets[0]=SECRET_NAME" -n NAMESPACE
Note Replace the placeholders in the
helm installcommand (REGISTRY_NAME,REPOSITORY_NAME,SECRET_NAME, andNAMESPACE) with your actual values.
These commands deploy NGINX Open Source on the Kubernetes cluster in the default configuration.
Tip: List all releases using
helm list
Configuration and installation details
This section describes credentials, configuration, and other installation options.
Resource requests and limits
Bitnami charts allow setting resource requests and limits for all containers inside the chart deployment. These are inside the resources value (check parameter table). Setting requests is essential for production workloads and these should be adapted to your specific use case.
To make this process easier, the chart contains the resourcesPreset values, which automatically sets the resources section according to different presets. Check these presets in the bitnami/common chart. However, in production workloads using resourcesPreset is discouraged as it may not fully adapt to your specific needs. Find more information on container resource management in the official Kubernetes documentation.
Prometheus metrics
This chart can be integrated with Prometheus by setting metrics.enabled to true. This will deploy a sidecar container with nginx-prometheus-exporter in all pods and will expose it via the NGINX service. This service will be have the necessary annotations to be automatically scraped by Prometheus.
Prometheus requirements
It is necessary to have a working installation of Prometheus or Prometheus Operator for the integration to work. Install the Bitnami Prometheus helm chart or the Bitnami Kube Prometheus helm chart to easily have a working Prometheus in your cluster.
Integration with Prometheus Operator
The chart can deploy ServiceMonitor objects for integration with Prometheus Operator installations. To do so, set the value metrics.serviceMonitor.enabled=true. Ensure that the Prometheus Operator CustomResourceDefinitions are installed in the cluster or it will fail with the following error:
no matches for kind "ServiceMonitor" in version "monitoring.coreos.com/v1"
Install the Bitnami Kube Prometheus helm chart for having the necessary CRDs and the Prometheus Operator.
Securing traffic using TLS
NGINX can encrypt communications by setting tls.enabled=true. The chart allows two configuration options:
- Provide your own secret using the
tls.certificatesSecretvalue. Also set the correct name of the certificate files using thetls.certFilename,tls.certKeyFilenameandtls.certCAFilenamevalues. - Have the chart auto-generate the certificates using
tls.autoGenerated=true.
Rolling VS Immutable tags
It is strongly recommended to use immutable tags in a production environment. This ensures your deployment does not change automatically if the same tag is updated with a different image.
Bitnami will release a new chart updating its containers if a new version of the main container, significant changes, or critical vulnerabilities exist.
Use a different NGINX version
To modify the application version used in this chart, specify a different version of the image using the image.tag parameter and/or a different repository using the image.repository parameter.
FIPS parameters
The FIPS parameters only have effect if you are using images from the Bitnami Secure Images catalog.
For more information on this new support, please refer to the FIPS Compliance section.
Backup and restore
To back up and restore Helm chart deployments on Kubernetes, you need to back up the persistent volumes from the source deployment and attach them to a new deployment using Velero, a Kubernetes backup/restore tool. Find the instructions for using Velero in this guide.
Deploying your custom web application
The NGINX chart allows you to deploy a custom web application using one of the following methods:
- Cloning from a git repository: Set
cloneStaticSiteFromGit.enabledtotrueand set the repository and branch using thecloneStaticSiteFromGit.repositoryandcloneStaticSiteFromGit.branchparameters. A sidecar will also pull the latest changes in an interval set bycloneStaticSitesFromGit.interval. - Providing a ConfigMap: Set the
staticSiteConfigmapvalue to mount a ConfigMap in the NGINX html folder. - Using an existing PVC: Set the
staticSitePVCvalue to mount an PersistentVolumeClaim with the static site content.
You can deploy a example web application using git deploying the chart with the following parameters:
cloneStaticSiteFromGit.enabled=true
cloneStaticSiteFromGit.repository=https://github.com/mdn/beginner-html-site-styled.git
cloneStaticSiteFromGit.branch=master
Providing a custom server block
This helm chart supports using custom custom server block for NGINX to use.
You can use the serverBlock or streamServerBlock value to provide a custom server block for NGINX to use. To do this, create a values files with your server block and install the chart using it:
serverBlock: |-
server {
listen 0.0.0.0:8080;
location / {
return 200 "hello!";
}
}
Warning: The above example is not compatible with enabling Prometheus metrics since it affects the
/statusendpoint.
In addition, you can also set an external ConfigMap with the configuration file. This is done by setting the existingServerBlockConfigmap parameter. Note that this will override the previous option.
Adding custom configuration by context
The NGINX chart supports context-based configuration includes, allowing you to add custom directives to specific NGINX contexts. You can provide configuration for three contexts:
- Main context: For global directives like module loading and worker processes
- Events context: For event-related directives
- HTTP context: For HTTP-related directives
Inline Context Configuration
You can provide inline configuration using the contextIncludes values:
contextIncludes:
main: |
# Load additional modules
load_module /opt/bitnami/nginx/modules/ngx_http_dav_module.so;
# Set worker processes
worker_processes auto;
events: |
# Increase worker connections
worker_connections 2048;
# Use epoll for better performance
use epoll;
http: |
# Enable gzip compression
gzip on;
gzip_vary on;
gzip_types text/plain application/json text/css;
# Security headers
add_header X-Frame-Options DENY;
add_header X-Content-Type-Options nosniff;
External ConfigMaps for Context Configuration
You can also reference external ConfigMaps for each context using lists:
existingContextMainConfigmaps:
- "nginx-modules-config"
- "nginx-main-directives"
existingContextEventsConfigmaps:
- "nginx-events-tuning"
existingContextHttpConfigmaps:
- "nginx-security-headers"
- "nginx-compression-config"
Mixed Configuration
You can combine inline configuration with external ConfigMaps:
contextIncludes:
main: |
worker_processes auto;
existingContextMainConfigmaps:
- "nginx-modules-config"
existingContextHttpConfigmaps:
- "nginx-security-config"
All configuration files are mounted to the appropriate directories (/opt/bitnami/nginx/conf/context.d/{main,events,http}/) and included using wildcards in the nginx.conf.
Adding extra environment variables
In case you want to add extra environment variables (useful for advanced operations like custom init scripts), you can use the extraEnvVars property.
extraEnvVars:
- name: LOG_LEVEL
value: error
Alternatively, you can use a ConfigMap or a Secret with the environment variables. To do so, use the extraEnvVarsCM or the extraEnvVarsSecret values.
Setting Pod's affinity
This chart allows you to set your custom affinity using the affinity parameter. Find more information about Pod's affinity in the kubernetes documentation.
As an alternative, you can use of the preset configurations for pod affinity, pod anti-affinity, and node affinity available at the bitnami/common chart. To do so, set the podAffinityPreset, podAntiAffinityPreset, or nodeAffinityPreset parameters.
Deploying extra resources
There are cases where you may want to deploy extra objects, such a ConfigMap containing your app's configuration or some extra deployment with a micro service used by your app. For covering this case, the chart allows adding the full specification of other objects using the extraDeploy parameter.
Gateway API
This chart provides support for exposing NGINX using the Gateway API and its HTTPRoute resource. If you have a Gateway controller installed on your cluster, such as APISIX, Contour, Envoy Gateway, NGINX Gateway Fabric or Kong Ingress Controller you can utilize the Gateway controller to serve your application. To enable Gateway API integration, set httpRoute.enabled to true.
The Gateway to be used can be customized by setting the httpRoute.parentRefs parameter. By default, it will reference a Gateway named gateway in the same namespace as the release.
You can specify the list of hostnames to be mapped to the deployment using the httpRoute.hostnames parameter. Additionally, you can customize the rules used to route the traffic to the service by modifying the httpRoute.matches and httpRoute.filters parameters or adding new rules using the httpRoute.extraRules parameter.
This chart also supports creating a BackendTLSPolicy to define the SNI the Gateway should use to connect to the NGINX backend pods
Deploy nginx with OpenTenant
Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has nginx on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.
- Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
- Place the chartnginx is pinned at v25.2.19 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
- ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below opentenant validate opentenant.yaml terraform init && terraform apply