I have server A which takes https requests like:
https://example.com/CHANGEME/example/index.html
I have Server B which takes:
https://CHANGEME.example.com/example/index.html
The client should only talk to Server A.
The question is: How do I have to configure the NGINX proxy in server A to use the string between the first 2 "/" and put this as subdomain?
Its important to cut that part out of the path and use it as subdomain.
Sure, when Server A gets the response from server B the subdomain needs to be rewritten back as path for the client.
Anything I tried didn't work and this seems to be an uncommon problem.
Is there any pattern rewrite function I'm missing?
thanks in advance!
edit: I would like to change my question a bit as it is not working as expected.
What I now would like to achieve is to do the reverse proxy based on a cookie value.
For testing I set a cookie named url with value CHANGEME.
In NGINX config I tried:
location / { resolver 8.8.8.8; proxy_pass https://$cookie_url.example.com; } Which is generally working and loading the desired website. The problem is that the client also tries to connect to a mqtt broker wss://example.com/mqtt and this gives me an error. I think, due to the missing cookie read option? Any chance to get this working?