Using a Proxy Server

Page last updated:

This topic describes how developers can use a proxy server with the buildpacks for their application.

Use a Proxy

You can assign proxy servers to environment variables. Proxy servers can be used to monitor your application’s traffic or to fetch your application’s dependencies.

A buildpack uses a proxy server if that buildpack contacts the internet during staging.

Note: The binary buildpack does not use a proxy server because it does not access the internet during staging.

Setting environment variables

Note: If you are using the Java buildpack, the http_proxy and https_proxy environment variables are not supported at runtime. The Java buildpack does not add the functionality to make proxies work at runtime.

  1. Add the following section to the env block of your application manifest YAML file:

    ---
    env:
      http_proxy: http://YOUR-HTTP-PROXY:PORT
      https_proxy: https://YOUR-HTTPS-PROXY:PORT
    

    Where:

    • YOUR-HTTP-PROXY is the address of your proxy server for HTTP requests.
    • YOUR-HTTPS-PROXY is the address of your proxy server for HTTPS requests.
    • PORT is the port number you are using for your proxy server.

  2. Set the environment variables with the Cloud Foundry Command Line Interface’s (cf CLI) cf set-env command by running these commands:

    cf set-env YOUR-APP http_proxy "http://YOUR-HTTP-PROXY:PORT"
    
    cf set-env YOUR-APP https_proxy "https://YOUR-HTTPS-PROXY:PORT"
    

    Where:

    • YOUR-APP is the name of your application.
    • YOUR-HTTP-PROXY is the address of your proxy server for HTTP requests.
    • YOUR-HTTPS-PROXY is the address of your proxy server for HTTPS requests.
    • PORT is the port number you are using for your proxy server.