NGINX Buildpack

The NGINX Paketo Buildpack supports the installation of the NGINX binary distribution onto the $PATH inside a container. This makes it available to subsequent buildpacks.

To build a sample app locally with this CNB using the pack CLI, run

git clone https://github.com/paketo-buildpacks/samples
cd samples/nginx
pack build my-app --buildpack gcr.io/paketo-buildpacks/nginx:latest
copy to clipboard
Copied!

See samples for how to run the app.

Supported Dependencies

The NGINX Paketo Buildpack supports several versions of NGINX. For more details on the specific versions supported in a given buildpack version, see the release notes.

Specifying an NGINX Version

The NGINX CNB (Cloud Native Buildpack) allows you to specify a version of NGINX to use during deployment. This version can be specified in a number of ways, including through buildpack.yml. When specifying a version of the NGINX engine, you must choose a version that is available within the buildpack.

Specifying a version of nginx is not required. In the case that it is not specified, the buildpack will provide the default version listed in the release notes.

Using buildpack.yml

To configure the buildpack to use NGINX v1.17.9 when deploying your app, for example, include the values below in your buildpack.yml file:

nginx:
  # this allows you to specify a version constaint for the `NGINX` dependency
  # any valid semver constaints (e.g. 1.* and 1.17.*) are also acceptable
  #
  # you can also specify "mainline" or "stable"
  version: 1.17.9
copy to clipboard
Copied!

Configurations

The NGINX buildpack supports two app configurations:

  1. When an nginx.conf file is present in your app’s source code, the buildpack will set up an NGINX server with that config.

  2. When the nginx.conf is not present in the app’s source code, the buildpack simply provides the NGINX dependency to subsequent buildpacks without actually setting up a server.

Custom NGINX configs

The NGINX CNB also supports data driven templates for nginx config. You may use variables like {{port}}, {{env "FOO"}} and {{module "ngx_stream_module"}}.

See the NGINX docs for more information about how to set up an nginx.conf file.

Last modified: October 16, 2020