NGINX Buildpack

Page last updated:

Overview

This topic describes how to configure your NGINX application for use with the NGINX buildpack and how to push your NGINX app to Cloud Foundry.

NGINX Setup

We recommend using the default NGINX directory structure for your NGINX webserver.

The NGINX webserver setup includes:

  • A root folder for all static web content
  • A mime type configuration file
  • A NGINX configuration file
  • A yaml file that defines what version of NGINX you want to use

Any custom configuration changes should be made from these default files to ensure compatability with the buildpack.

Dynamic Modules

Buildpack-Provided Modules

For nginx-buildpack v0.0.5 and later, the following dynamic modules will be built in and loadable by NGINX’s load_module directive.

  • Stream module: ngx_stream_module.so

To use a built-in dynamic module, use the load_module {{.NginxModulesDir}}/<module file name>; syntax at the top of your nginx.conf.

For example, to use the stream module:

  load_module {{.NginxModulesDir}}/ngx_stream_module.so;

User-Provided Modules

Users can supply their own dynamic modules by placing them in the application directory and supplying a path to the module in the nginx.conf file. To configure a user-provided dynamic module, use the following syntax:

  load_module <path to module>;

For example, to use a module called my_module.so inside a modules directory:

  load_module modules/my_module.so;

Push Your App

Follow the steps below to push your application.

Step Action
1. Use the cf push APP_NAME command to push your app. Replace APP_NAME with the name you want to give your application. For example:
$ cf push my-app
Creating app my-app in org sample-org / space sample-space as username@example.com...
OK
…
requested state: started
instances: 1/1
usage: 1GB x 1 instances
urls: my-app.example.com
If you do not have the buildpack, or the installed version is out-of-date, use the -b option to specify the buildpack as follows:
cf push APP_NAME -b https://github.com/cloudfoundry/nginx-buildpack.git
2. Find the URL of your app in the output from the push command and navigate to it to see your NGINX app running.

Buildpack Support

A number of channels exist where you can get more help when using the NGINX buildpack, or with developing your own NGINX buildpack.

  • NGINX Buildpack Repository in Github: Find more information about using and extending the NGINX buildpack in GitHub repository.

  • Release Notes: Find current information about this buildpack on the NGINX buildpack release page in GitHub.

  • Slack: Join the #buildpacks channel in the Cloud Foundry Slack community.

Create a pull request or raise an issue on the source for this page in GitHub