marathon-lb
marathon-lb copied to clipboard
Routing to webapi and spa based on path
Hi
I have my SPA (single page application) and WEBAPI running in seperate service ports in marathon as docker containers. They individually work well , However I want that through the same service port both the applications should be exposed . By default all requests should be routed to the spa but if any request come with a pre-configured path like /webapi/api/v1/*
, it should be routed to the WEBAPI.
I don not have any virtual hosts , Only two docker containers configured to run on seperate service ports. Do I need to create virtual hosts and if so how to do that. Here are the configuration that i have for the apps:
Web API
{
"id": "nsri-webapi",
"container": {
"docker": {
"image": "roopam/webapi",
"network": "BRIDGE",
"portMappings": [
{
"containerPort": 8625,
"hostPort": 0,
"servicePort": 8002,
"protocol": "tcp"
}
]
},
"type": "DOCKER"
},
"labels": {
"HAPROXY_GROUP": "external"
},
"env": {
"API_PORT" : "8625",
},
"healthChecks": [
{
"protocol": "HTTP",
"path": "/api/v1/healthcheck",
"gracePeriodSeconds": 10,
"intervalSeconds": 30
}
],
"cpus": 0.03,
"mem": 256.0,
"instances": 1,
"upgradeStrategy": {
"minimumHealthCapacity": 0.8,
"maximumOverCapacity": 0.1
}
}
SPA
{
"id": "nsri-spa",
"container": {
"docker": {
"image": "roopam/spa",
"network": "BRIDGE",
"portMappings": [
{
"containerPort": 8626,
"hostPort": 0,
"servicePort": 8001,
"protocol": "tcp"
}
]
},
"type": "DOCKER"
},
"labels": {
"HAPROXY_GROUP": "external"
},
"env": {
"STATIC_PORT" : "8626"
},
"healthChecks": [
{
"protocol": "HTTP",
"path": "/",
"gracePeriodSeconds": 10,
"intervalSeconds": 30
}
],
"cpus": 0.03,
"mem": 256.0,
"instances": 1,
"upgradeStrategy": {
"minimumHealthCapacity": 0.8,
"maximumOverCapacity": 0.1
}
}