Dynamic Path from plugin

Hi

I am trying to write a new plugin that dynamically generates upstream url (based on header value).
So far I successfully changed upstream host using:

ngx.ctx.balancer_address

but I need to change path for upstream url too, do you know how can I achieve this ?
I found somewhere that ngx.var.upstream_url but it gives me an error:
“variable “upstream_url” not found for writing;”

ngx.var.upstream_uri

Sorry for late reply but thanks :slight_smile: for pointing this variable. I will try it tonight and let post solution for future reference if works.

A more thorough explanation can be found here:

Thanks for your response, however I had to park this plugin as we do not need it currently. Might come back to it in near future and will try out your solution.

Thanks again.