This topic tells you how to use the Tanzu HTTPD Buildpack.
The HTTPD Tanzu Buildpack supports the installation and running of the Apache HTTP Server.
NoteThe Full stack is required because HTTPD relies on operating system libraries only present in the Full stack.
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.
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"
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.
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
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
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
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
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.
When the HTTPD Buildpack participates in a build, it will contribute in one of three ways:
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.
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.
When the BP_WEB_SERVER
is set to httpd
, the buildpack will set up an Apache HTTP server with a default 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.
You can configure the HTTPD using service bindings.
type |
Required Files | # Bindings of This Type Accepted |
---|---|---|
htpasswd |
type , .htpasswd |
0 or 1 |