Compute Services

Context path routes for your Bluemix Cloud Foundry apps

Share this post:

Recently, I have experimented with combining several runtimes and apps. You can read about my experiences in the blog “Manifest files: Understand Domain and Host Property for Your Bluemix Cloud Foundry Apps“. The reason behind my experiments were to put together a sample for Context Path Routing for use with IBM Bluemix Cloud Foundry apps. But what are context path routes and what does the sample do? Here are the details.

Cloud Foundry introduced Context Path Routing last year. Until then, there was the requirement that each app (or service) was served from its own hostname. Now, apps can share a host with each app being served from a specific path on that host. Here are three examples:

Two Apps, Three Routes - Context Path Routes

One Domain, Two Apps, Three Routes – Sample App using Context Path Routes

  1. When building a larger website, there could be several so-called microsites embedded. With Context Path Routing it is possible to serve, e.g., example.com from one web app and example.com/user-management or example.com/news from other apps. All these apps could be written in different programming languages such as Node.js, Python, Java and others.
  2. For a more complex microservice-based app, following the principles of the Twelve Factor App, there could be several (backing) services involved. The app and each would require their own hostname. With Context Path Routing the app could use app.mybluemix.net and services could be served from app.mybluemix.net/service1, app.mybluemix.net/service2, etc.
  3. It is possible to encrypt custom domains on Bluemix with the “Let’s Encrypt” Certificate Authority and related tools. It is based on the same principles as example one. Read here about how to use Context Path Routes and “Let’s Encrypt” to secure your custom domain.

Getting Started with Context Path Routes

So how could you use the new routing feature? There are several Cloud Foundry CLI commands related to routing. They allow to specify an additional path for application routes. Manifest files also have optional route properties that could be set. To get started, take a look at my Context Path Routing sample on GitHub for details. It has two small apps written in Python and Node.js that share a host using specific paths. The apps can be deployed with a single command and allow to experiment with context paths. The “What this samples does” section gives you some ideas.

Technical Offering Manager / Developer Advocate

More Compute Services stories
May 3, 2019

Kubernetes Tutorials: 5 Ways to Get You Building Fast

Ready to start working with Kubernetes? Want to build your Kubernetes skills? The five tutorials in this post will teach you everything you need to know about how to manage your containerized apps with Kubernetes.

Continue reading

May 3, 2019

Using Portworx to Deploy and Manage an HA MySQL Cluster on IBM Cloud Kubernetes Service

This tutorial is a walkthrough of the steps involved in deploying and managing a highly available MySQL cluster on IBM Cloud Kubernetes Service.

Continue reading

May 2, 2019

Kubernetes v1.14.1 Now Available in IBM Cloud Kubernetes Service

We are excited to announce the availability of Kubernetes v1.14.1 for your clusters that are running in IBM Cloud Kubernetes Service. IBM Cloud Kubernetes Service continues to be the first public managed Kubernetes service to support the latest upstream versions from the community.

Continue reading