Configuring SSL/TLS Termination at HAProxy

Page last updated:

Both Pivotal Application Service (PAS) and Isolation Segments for Pivotal Cloud Foundry include an HAProxy instance.

HAProxy is appropriate to use in a deployment when features are needed that are offered by HAProxy but are not offered by the CF Routers or IaaS-provided load balancers such as with Azure load balancers. These include filtering of protected domains from trusted networks.

While HAProxy instances provide load balancing for the Gorouters, HAProxy is not itself highly available. For production environments, use a highly-available load balancer to scale HAProxy horizontally. The load balancer does not need to terminate TLS or even operate at layer 7 (HTTP); it can simply provide layer 4 load balancing of TCP connections. Use of HAProxy does not remove the need for CF Routers; the Gorouter must always be deployed for HTTP applications, and TCP Router for non-HTTP applications.

You can generate a self-signed certificate for HAProxy if you do not want to obtain a signed certificate from a well-known certificate authority.

Procedure: Terminate SSL/TLS at HAProxy

To configure SSL termination on HAProxy in PCF:

  1. Navigate to the Ops Manager Installation Dashboard.

  2. Click the Pivotal Application Service tile in the Installation Dashboard.

  3. Click Networking.

  4. Configure the following based on the IaaS of your PCF deployment.

    If your PCF deployment is on: Then configure the following: See also:
    OpenStack or vSphere Decide whether you want your HAProxy to be highly available.
    • If you need highly available HAProxy, then perform the following steps:
      1. Choose an IP address for each HAProxy instance on the subnet where you deployed PCF.
      2. In the HAProxy IPs field of the Networking pane, enter the IP addresses you have selected for your HAProxy instances.
      3. Configure your load balancer (for example, F5 or NSX) to forward domain names to the HAProxy IP addresses.
    • If you do not require high availability (for example, you are setting up a development environment), then perform the following steps:
      1. Skip setting up the load balancer.
      2. Choose one IP address for the single HAProxy instance.
      3. Configure DNS to point at the IP address. See How to Set Up DNS for HAProxy.
    For more information, see Configuring PAS.
    AWS, GCP or Azure
    1. Leave the HAProxy IP address blank.
    2. In the Resource Config page of PAS tile, locate the HAProxy job.
    3. In the Load Balancer column for the HAProxy job, specify the appropriate IaaS load balancer resource.

    For more information, see Configuring PAS.

  5. In the Certificates and Private Keys for HAProxy and Router field, click the Add button to define at least one certificate keypair for HAProxy and Router. For each certificate keypair that you add, assign a name, enter the PEM-encoded certificate chain and PEM-encoded private key. You can either upload your own certificate or generate an RSA certificate in PAS. For options and instructions on creating a certificate for your wildcard domains, see the Creating a Wildcard Certificate for PCF Deployments in the Providing a Certificate for Your TLS Termination Point topic.

  6. In the Minimum version of TLS supported by HAProxy and Router, select the minimum version of TLS to use in HAProxy communications. HAProxy use TLS v1.2 by default. If you need to accommodate clients that use an older version of TLS, select a lower minimum version. For a list of TLS ciphers supported by the HAProxy, see the TLS Cipher Suites section of the TLS Connections in PCF topic.

  7. Under HAProxy forwards requests to Router over TLS, leave Enabled selected and provide the backend certificate authority.

  8. If you want to use a specific set of TLS ciphers for HAProxy, configure TLS Cipher Suites for HAProxy. Enter an ordered, colon-separated list of TLS cipher suites in the OpenSSL format. For example, if you have selected support for an earlier version of TLS, you can enter cipher suites supported by this version. For a list of TLS ciphers supported by the HAProxy, see the TLS Cipher Suites section of the TLS Connections in PCF topic.

  9. If you expect requests larger than the default maximum of 16 KB, enter a new value in bytes for HAProxy Request Max Buffer Size. You may need to do this, for example, to support apps that embed a large cookie or query string values in headers.

  10. If you want to force browsers to use HTTPS when making requests to HAProxy, select Enable in the HAProxy support for HSTS field and complete the following optional configuration steps:

    1. (Optional) Enter a Max Age in Seconds for the HSTS request. By default, the age is set to one year. HAProxy will force HTTPS requests from browsers for the duration of this setting.
    2. (Optional) Select the Include Subdomains checkbox to force browsers to use HTTPS requests for all component subdomains.
    3. (Optional) Select the Enable Preload checkbox to force instances of Google Chrome, Firefox, and Safari that access your HAProxy to refer to their built-in lists of known hosts that require HTTPS, of which HAProxy is one. This ensures that the first contact a browser has with your HAProxy is an HTTPS request, even if the browser has not yet received an HSTS header from your HAProxy.
  11. (Optional) If you are not using SSL encryption or if you are using self-signed certificates, you can select Disable SSL certificate verification for this environment. Selecting this checkbox also disables SSL verification for route services.

    Note:Use this checkbox only for development and testing environments. Do not select it for production environments.

    u do not want HAProxy or the Gorouter to accept any non-encrypted HTTP traffic, select the Disable HTTP on HAProxy and Router checkbox.

  12. In the Configure the CF Router support for the X-Forwarded-Client-Cert header field, select Always forward the XFCC header in the request, regardless of the whether the client connection is mTLS.

  13. (Optional) If your PCF deployment uses HAProxy and you want it to receive traffic only from specific sources, use the following fields:

    • Protected Domains: Enter a comma-separated list of domains from which PCF can receive traffic.
    • Trusted CIDRs: Optionally, enter a space-separated list of CIDRs to limit which IP addresses from the protected domains can send traffic to PCF.
  14. Click Save.

How to Set Up DNS for HAProxy

You only need to perform this procedure if you are using one instance of HAProxy such as in a development environment. If you would like HAProxy to be highly available, you must have a load balancer in front of it. In this case, you would point DNS at the load balancer.

To use a single instance HAProxy load balancer in a vSphere or OpenStack deployment, create a wildcard A record in your DNS and configure some fields in the PAS product tile.

  1. Create an A record in your DNS that points to the HAProxy IP address. The A record associates the System Domain and Apps Domain that you configure in the Domains section of the PAS tile with the HAProxy IP address.

    For example, with as the main subdomain for your Cloud Foundry (CF) deployment and an HAProxy IP address, you must create an A record in your DNS that serves and points *.cf to

    Name Type Data Domain
    *.cf A
  2. Use the Linux host command to test your DNS entry. The host command should return your HAProxy IP address.


    $ host has address
    $ host has address