Fix route-based port mapping: use hostPort as container port
allocateRoutePorts() was using the route's port field (the mc-proxy listener port, e.g. 443) as the container internal port in the podman port mapping. For L7 routes, apps don't listen on the mc-proxy port — they read $PORT (set to the assigned host port) and listen on that. The mapping host:53204 → container:443 fails because nothing listens on 443 inside the container. Fix: use hostPort as both the host and container port, so $PORT = host port = container port. Broke mcdoc in production (manually fixed, now permanently fixed). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -198,7 +198,10 @@ func (a *Agent) allocateRoutePorts(service, component string, routes []registry.
|
||||
return nil, nil, fmt.Errorf("store host port for route %q: %w", r.Name, err)
|
||||
}
|
||||
|
||||
ports = append(ports, fmt.Sprintf("127.0.0.1:%d:%d", hostPort, r.Port))
|
||||
// The container port must match hostPort (which is also set as $PORT),
|
||||
// so the app's listen address matches the podman port mapping.
|
||||
// r.Port is the mc-proxy listener port, NOT the container port.
|
||||
ports = append(ports, fmt.Sprintf("127.0.0.1:%d:%d", hostPort, hostPort))
|
||||
|
||||
if len(routes) == 1 {
|
||||
env = append(env, fmt.Sprintf("PORT=%d", hostPort))
|
||||
|
||||
Reference in New Issue
Block a user