Best way to route stateful service without Kube?

I’m trying to find a simple way to route any number of stateful instances via nginx.
The ““ideal”” scenario would be to map every instance in a specific path /instance1/* /instance2/*, but currently i would have to explicitly map dependencies on nginx service description HCL local ports one by one.
The only solution can i see is to dynamically generate and reload the service HCL, but i don’t really like this solution.