Advanced scenarios call for a more flexible configuration of your sandbox environment’s application load balancer. This may include cases where your sandbox environment includes has applications and you need to redirect the traffic to certain applications based on a URL path. You can do this by defining port accessibility in the blueprint and application YAMLs, where external ports are defined in the blueprint YAML and internal ports in the application YAML.
To redirect traffic:
- In the sandbox environment blueprint YAML, add an Ingress element. The following is an example of a blueprint that includes a listener responsible for redirecting incoming traffic from port 80 to two different environment applications (application-api and application-web):
ingress: listeners: - http: 80 rules: - path: /api/* host: sandbox.sometest.com application: application-api port: 3001 shortcut: sandbox.sometest.com/api/index - host: sandbox.sometest.com application: application-web port: 3000 shortcut: sandbox.sometest.com
In the above example, ingress is defined to listen to port 80 of the application load balancer. The API and the web application each are assigned with a unique hostname and port.
The redirection of incoming traffic to the sandbox environment's applications is defined as follows:
- Incoming traffic from sandbox.sometest.com will be redirected to port 3000 to the Web application.
- Incoming traffic from sandbox.sometest.com/api/* will be redirected to port 3001 to the API application.
- In the application YAML, add an ingress health check. The load balancer runs the health check for each application instance to check whether the instance is ready to accept incoming traffic. The following is an example of a health check defined in the web application YAML:
infrastructure: connectivity: internal: - port_info: port: 3000 ingress-healthcheck: healthy-threshold: 5 interval: 30 path: / status-codes: 200-299 timeout: 5 unhealthy-threshold: 2
For details, see The Application YAML File.