This topic tells you how to use the Tanzu HTTPD Buildpack.

HTTPD Buildpack

The HTTPD Tanzu Buildpack supports the installation and running of the Apache HTTP Server.

NOTE: The Full stack is required because HTTPD relies on operating system libraries only present in the Full stack.

Specifying an HTTPD Version

The HTTPD CNB (Cloud Native Buildpack) allows you to specify a version of the Apache HTTP Server to use during deployment. This version can be specified through the BP_HTTPD_VERSION environment variable. When specifying a version of the Apache HTTP Server, you must choose a version that is available within the buildpack.

Specifying a version of httpd is not required. In the case that it is not specified, the buildpack will provide a default version.

Using BP_HTTPD_VERSION

For e.g. to configure the buildpack to use HTTPD v2.4.46 when deploying your app, set the following environment variable at build time, either directly (e.g. pack build my-app --env BP_HTTPD_VERSION=2.4.*) or through a project.toml file:

BP_HTTPD_VERSION="2.4.46"

Automatically Generate an httpd.conf

The Apache HTTPD Server Buildpack supports building static applications that do not include an httpd.conf. When the BP_WEB_SERVER environment variable is set to httpd, the buildpack will generate an http.conf during the build process.

BP_WEB_SERVER=httpd

It is possible to configure the generated httpd.conf in several ways. Each option is configurable with an environment variable or service binding, as seen below.

Set the Root Directory for Static Files

The BP_WEB_SERVER_ROOT variable allows you to modify the location of the static files served by the web server. Set the BP_WEB_SERVER_ROOT variable to an absolute file path or a file path relative to /workspace. For example, setting BP_WEB_SERVER_ROOT=my-build-directory changes the file path of served files to /workspace/my-build-directory.

BP_WEB_SERVER_ROOT=htdocs

Enable Push-State Routing

The BP_WEB_SERVER_ENABLE_PUSH_STATE variable enables push state routing functionality. This is useful for single-page web applications.

BP_WEB_SERVER_ENABLE_PUSH_STATE=true

Redirect HTTP Requests to HTTPS

The BP_WEB_SERVER_FORCE_HTTPS variable enables enforcing HTTPS for server connections. HTTP requests will be redirected to the corresponding HTTPS endpoint.

BP_WEB_SERVER_FORCE_HTTPS=true

Set Up Basic Authentication

You are able to provide basic authentication credentials via a service bindings of type htpasswd that specifies the contents of a .htpasswd file. The service binding should have the following directory structure:

binding
└── type
└── .htpasswd

Start an HTTPD Server at App Launch Time

Include an httpd.conf file in your application's source code or set BP_WEB_SERVER=httpd in the build environment to automatically generate one. The HTTPD buildpack will install the Apache HTTP Server binary and configure it to start when the app image launches.

Behavior

When the HTTPD Buildpack participates in a build, it will contribute in one of three ways:

  1. When an httpd.conf file is present in your app's source code, the buildpack will set up an Apache HTTP server with that config.

  2. When the httpd.conf is not present in the app's source code, the buildpack simply provides the Apache HTTP Server dependency to subsequent buildpacks without actually setting up a server.

  3. When the BP_WEB_SERVER is set to httpd, the buildpack will set up an Apache HTTP server with a default configuration.

Environment Variable Configuration

BP_LIVE_RELOAD_ENABLED

Enables reloadable processes.

BP_HTTPD_VERSION

Allows you to specify the version of Apache HTTP Server that is installed.

BP_WEB_SERVER

When the value is set to httpd the buildpack will generate a default httpd.conf.

BP_WEB_SERVER_ROOT

Defaults to public, setting this allows you to modify the location of the static files served by the web server with either an absolute file path or a file path relative to /workspace.

BP_WEB_SERVER_ENABLE_PUSH_STATE

Enables push state routing functionality.

BP_WEB_SERVER_FORCE_HTTPS

Allows you to enforce HTTPS for server connections by redirecting all requests to use the HTTPS protocol.

Supported Service Bindings

The HTTPD buildpack can be configured using service bindings.

type Required Files # Bindings of This Type Accepted
htpasswd type, .htpasswd 0 or 1
check-circle-line exclamation-circle-line close-line
Scroll to top icon