I have a CF application that opens two ports. AFAIK CF can create routing on only for one of them - to the one that is located in VCAP_APP_PORT
or PORT
As stated in some other comments it is now possible in CF to use multiple ports for your application. There is a chapter in the CF documentation which describes how to do it. I followed the instructions and still had some trouble to fully understand it, that's why I provide a step by step guide here with some explanations (replace all variables in [] with the actual values):
cf app [APP_NAME] --guid
cf curl /v2/apps/[APP_GUID] -X PUT -d '{"ports": [8080, 8081]}'
cf curl /v2/routes?q=host:[HOST_NAME]
or with cf curl /v2/apps/[APP_GUID]/routes
and save the guid of the route that points to your app ([ROUTE_GUID]).cf curl /v2/routes/[ROUTE_GUID]/route_mappings
. With cf curl /v2/route_mappings -X POST -d '{"app_guid": "[APP_GUID]", "route_guid": "[ROUTE_GUID]", "app_port": 8081}'
you add a mapping to a route (e.g. here to 8081).cf curl /v2/routes/[ROUTE_GUID]/route_mappings
to show all route mappings. Then extract the guid of the route mapping that should be deleted (e.g. the one to port 8080). Finally, run cf curl /v2/route_mappings/[GUID_ROUTE_MAPPING] -X DELETE
to delete the route mapping you do not need.Now your CF app should be reachable on another port than 8080 when the newly configured route is used.