Using test app: https://github.com/cloudfoundry/cf-acceptance-tests/tree/master/assets/hello-routing and bosh-lite. This app will display the VCAP_APPLICATION name of the running app.
i.e. Hello, <VCAP_APPLICATION> at index <CF_INSTANCE_INDEX>
Push app
cf push hello
Curl app and see the VCAP_APPLICATION
curl hello.bosh-lite.com
Hello, hello at index: 0!
Push 2nd app
cf push hello2
Curl 2nd app and see the VCAP_APPLICATION
curl hello2.bosh-lite.com
Hello, hello2 at index: 0!
List apps / urls
cf apps
Getting apps in org o / space s as admin...
OK
name requested state instances memory disk urls
hello started 1/1 256M 1G hello.bosh-lite.com
hello2 started 1/1 256M 1G hello2.bosh-lite.com
Map a route with a context path and associate with 2nd app deployed
cf map-route hello2 bosh-lite.com --hostname hello --path v2
Creating route hello.bosh-lite.com/v2 for org o / space s as admin...
OK
Adding route hello.bosh-lite.com/v2 to app hello2 in org o / space s as admin...
OK
List routes:
cf routes
Getting routes as admin ...
space host domain path apps
s hello bosh-lite.com hello
s hello2 bosh-lite.com hello2
s hello bosh-lite.com /v2 hello2
Also on bosh-lite, you can dump the gorouter routing table to see routes and info:
curl http://router:router@10.244.0.22:8080/routes | jq .
You should see something like this for these route entries:
"hello.bosh-lite.com": [
{
"address": "10.244.0.26:61012",
"ttl": 0
}
],
"hello.bosh-lite.com/v2": [
{
"address": "10.244.0.26:61013",
"ttl": 0
}
],
"hello2.bosh-lite.com": [
{
"address": "10.244.0.26:61013",
"ttl": 0
}
],
Curl route with context path and see the VCAP_APPLICATION It should route to the 2nd app deployed.
curl hello.bosh-lite.com/v2
Hello, hello2 at index: 0!