Gitlab-ce-15.2.4 kas in docker with custom port external url

We have a self-managed gitlab instance running in docker container and an external url set as: https://subdomain.domain.com:50080

I’ve put gitlab_kas[‘enable’] = true in the docker-compose file in “GITLAB_OMNIBUS_CONFIG: |” and try to add the agent with helm in “Connect a Kubernetes cluster”, but the kasAddress does not contain the 50080 port:

–set config.kasAddress=wss://subdomain.domain.com:/-/kubernetes-agent/

and the agent pod gives this error:

{“level”:“error”,“time”:“2022-09-07T07:32:50.899Z”,“msg”:“Error handling a connection”,“mod_name”:“reverse_tunnel”,“error”:“Connect(): rpc error: code = Unavailable desc = connection error: desc = "transport: Error while dialing failed to WebSocket dial: failed to send handshake request: Get \"https://subdomain.domain.com/-/kubernetes-agent/\\\”: context deadline exceeded""}

If I add the port manually to the kasAddress in the helm command the gitlab-kas/current log gives this error:

2022-09-07_07:44:01.55475 {“level”:“error”,“time”:“2022-09-07T07:44:01.553Z”,“msg”:“AgentInfo()”,“correlation_id”:“01GCBE78S0SX2BA5B48M3813W4”,“grpc_service”:“gitlab.agent.reverse_tunnel.rpc.ReverseTunnel”,“grpc_method”:“Connect”,“error”:“Get "https://subdomain.domain.com:50080/api/v4/internal/kubernetes/agent_info\”: dial tcp 82.77.16.135:50080: i/o timeout"}

The problem was upstream on the mikrotik router. I needed a masquerade nat rule for the srcnat chain. In other words, gitlab was not able to reach itself on the public IP