The cf-proxy tool simplifies the connection between local applications and remote services hosted on SAP BTP. It enables developers to deploy applications to SAP BTP via Cloud Foundry, set up a local proxy to route requests securely, and integrate XSUAA and Destination services for authentication and connectivity. Additionally, it supports creating SSH tunnels for secure access to remote resources. This tool is particularly useful for testing, debugging, and securely interacting with cloud services directly from a local environment.
This guide provides instructions for setting up and configuring a local proxy to connect with a remote cf-proxy service. By following the steps outlined below, you will:
- Set environment variables for proxy usage.
- Install the project dependencies.
- Configure scripts and bindings for XSUAA and proxy startup.
Ensure to have Node.js and npm installed before proceeding.
The remote application is already available in the /remote folder. Follow these steps to deploy it to SAP Business Technology Platform (BTP):
- SAP BTP Access: Ensure you have access to a subaccount and space in SAP BTP.
- Cloud Foundry CLI: Install the Cloud Foundry CLI and authenticate to your BTP environment.
- Pre-configured Services: Ensure the required services (e.g., XSUAA, destination service) are already created in your BTP subaccount.
- Node.js Environment: The application uses Node.js—make sure Node.js is supported in the configured buildpacks.
Open a terminal and navigate to the remote application folder:
cd remoteLog in to the Cloud Foundry environment using the following command:
cf login -a <API_ENDPOINT> -o <ORG> -s <SPACE> --ssoReplace:
<API_ENDPOINT>: Your BTP API endpoint (e.g.,https://api.cf.<region>.hana.ondemand.com).<ORG>: Your organization name in BTP.<SPACE>: Your space name in BTP.
If additional configuration is needed, modify the file accordingly.
Deploy the remote app to SAP BTP using the following command:
npm run deployThe npm run deploy command will:
- Build the application from the
/remotefolder. - Upload the application.
- Bind any configured services from the
manifest.yml. - Start the application in your specified space.
Once the deployment completes:
- Go to the SAP BTP Cockpit.
- Navigate to your subaccount → space → applications.
- Verify that the application (e.g.,
remote-app) is running.
Copy the application URL from the BTP cockpit or the CLI output. For example:
https://remote-app.<region>.cfapps.<landscape>.hana.ondemand.com
Use this URL to access the remote application.
- Service Bindings: If you need to bind new services to the existing application, use the
cf bind-servicecommand:
cf bind-service remote-app <SERVICE-NAME>
cf restage remote-app- Log Monitoring: Check logs if the deployment encounters issues:
cf logs remote-app --recentNavigate to the /remote folder and execute cf push. The application should be deployed and accessible in your defined SAP BTP space.
First, install the necessary dependencies:
npm install -g .Create a .env file in the root directory, which binds the proxy to a remote service:
cf-proxy bind https://cf-proxy.cfapps.eu10.hana.ondemand.comReplace https://cf-proxy.cfapps.eu10.hana.ondemand.com with the URL of your SAP BTP destination proxy's endpoint.
To start the proxy locally, add the following to your app/package.json file’s scripts section:
"proxy": "cf-proxy run"
If you use XSUAA services, include the binding script in the root package.json:
"bind:xsuaa": "npx cds-ts bind uaa --to XSUAA-RESOURCE-NAME --kind xsuaa --for hybrid"
Replace XSUAA-RESOURCE-NAME with the name of your XSUAA service instance. This binds your application securely to the respective resource.
set http_proxy=http://127.0.0.1:8887
set https_proxy=http://127.0.0.1:8887
set all_proxy=http://127.0.0.1:8887export http_proxy=http://127.0.0.1:8887
export https_proxy=http://127.0.0.1:8887
export all_proxy=http://127.0.0.1:8887Once all steps are completed, you can:
- Run the proxy using
npm run proxy. - Test your application to ensure proxy settings are applied correctly.
- Refer to the official documentation for additional features or advanced configurations.
An SSH tunnel establishes a secure connection between your local machine and a remote host—useful for accessing resources through a Cloud Foundry application. The cf-proxy utility provides commands to easily start and stop an SSH tunnel.
To start the SSH tunnel, use the following command:
cf-proxy sshTunnel:start <cf_app> <remote_host> [port]<cf_app>: The name of the Cloud Foundry application.<remote_host>: The hostname or IP address of the remote server you want to connect to.[port](optional): The local port for the SSH tunnel. Defaults to1348if not specified.
To stop the SSH tunnel running on a specific local port, use the following command:
cf-proxy sshTunnel:stop --port <port><port>: The local port on which the SSH tunnel is running.