Path based routing

I will first admit I have no idea if this is even possible, other than reading through:

https://docs.aws.amazon.com/elasticloadbalancing/latest/application/tutorial-load-balancer-routing.html

I would like to be able to have two services with the same domain, except have one of the services require a set of specific path rules. If none of the path rules are met then route the traffic to the other service.

Examples:

– admin services at domain.com/admin instead of admin.domain.com
– api services at domain.com/api instead of api.domain.com

1 Like

I would personally benefit from the ability to drop down a level and define ALB rules directly, which could then also be used for path based routing.

My use case, specifically, is routing requests to single-tenant applications, based on the contents of the Authorization header.

An api gateway, of sorts, without making another trip through the load balancer.

Maybe something along these lines:

services:
  one_live:
    build: .
    domain: api.example.com
    routing_rules:
      - type: Http header
        header: Authorization
        is: [Bearer one_live_*]
    environment:
      DATABASE_NAME: one_live

  one_test:
    build: .
    domain: api.example.com
    routing_rules:
      - type: Http header
        header: Authorization
        is: [Bearer one_test_*]
    environment:
      DATABASE_NAME: one_test

  two_live:
    build: .
    domain: api.example.com
    routing_rules:
      - type: Http header
        header: Authorization
        is: [Bearer two_live_*]
    environment:
      DATABASE_NAME: two_live

  two_test:
    build: .
    domain: api.example.com
    routing_rules:
      - type: Http header
        header: Authorization
        is: [Bearer two_test_*]
    environment:
      DATABASE_NAME: two_test

Right now I’m on the fence between manually adding these rules to the ALB, or exposing an nginx reverse proxy that will route to internal services.

Either way, convox greatly simplifies my life, and I thank you for that!