Getting Started with Pivotal Spring Cloud Gateway

Page last updated:

See below for steps to get started using Pivotal Spring Cloud Gateway. The examples below use Pivotal Spring Cloud Gateway to quickly create an API gateway.

Set Up a Pivotal SSO Service Plan

To use single sign-on, you must install the Pivotal Single Sign-On (Pivotal SSO) tile and create a Pivotal SSO service plan that is available to the p-spring-cloud-gateway-service org.

For more information about using Pivotal SSO with Pivotal Spring Cloud Gateway, see Using Pivotal Single Sign-On.

Create a Gateway Service Instance

Create a new Pivotal Spring Cloud Gateway service instance, using the -c flag to pass the Pivotal SSO plan to use (via the sso.plan parameter) and the host to use (via the host parameter). In the following example, the service instance is named my-gateway, the Pivotal SSO plan is named my-sso-plan, and the host for the service instance is my-gateway:

$ cf create-service p.gateway standard my-gateway -c '{"sso": { "plan": "my-sso-plan" }, "host": "my-gateway"}'

You can also specify the domain to use for the service instance, using the domain parameter. Omitting the domain parameter, as in this example, will create the service instance’s route using the specified host and the default external domain for Pivotal Application Service (PAS).

For more information about creating and managing service instances, see Managing Service Instances.

Bind a Service App and Include Route Configuration

Given an existing microservice app myservice, bind the my-gateway service instance to the myservice app, using the -c flag to include route configuration for the app:

$ cf bind-service myservice my-gateway -c '{"routes": [{"path": "/myservice/**", "sso-enabled": true}]}'

In this example, the app is bound and the Gateway service instance adds a route for the myservice app. The route uses the path /myservice/** for the myservice app and uses SSO (provided by the my-sso-plan service plan of the Pivotal SSO tile).

For more information about configuring routes for service apps on a Gateway service instance, see Configuring Routes.

Access an App Endpoint at the Gateway Path

In a browser, access an endpoint on the myservice app, using the path provided for the app’s route in the Gateway service instance. The path consists of:

  • the host used for the Gateway service instance
  • the domain used for the Gateway service instance
  • the path configured for the app’s Gateway route

In this example, the Gateway service instance uses the host my-gateway (the name of the service instance) and the PAS default external domain, and the Gateway service instance’s route for the myservice app uses the path /myservice/**. To access the myservice app’s customers endpoint in this example, you would visit:


where [DEFAULT_DOMAIN] is the PAS default external domain.

If you have configured a custom host (for example, my-custom-host) for the service instance, you might access the customers endpoint by visiting:


If you have configured a custom domain (for example, for the service instance, you might access the endpoint by visiting:

For information about configuring a Gateway service instance’s host and domain, see the Host and Domain section of Managing Service Instances.

Visit the Gateway Service Instance’s Dashboard

To find the dashboard for the Gateway service instance, you can use the cf service command:

$ cf service my-gateway
Showing info of service my-gateway in org myorg / space dev as user...

name:             my-gateway
service:          p.gateway
plan:             standard
description:      Pivotal Spring Cloud Gateway
service broker:   scg-service-broker


Visit the URL given for dashboard.

For more information about the Gateway dashboard, see Using the Dashboard.