Dynamic nginx Configuration: Proxy to Backend based on Host of Frontend
I am looking for an nginx configuration that routes specific requests from my frontend to my backend.
Frontend URL: https://my-app-ui-[stage].org
Backend URL: https://my-app-[stage].org
[stage] being a suffix that changes for our different stage environments. On production, this part is missing entirely.
All requests with a path beginning mit /api should be routed to the backend.
The nginx configuration should be dynamic, so that I can use the same on all stages.
I have been looking into nginx reverse proxy settings: docs.nginx.com/nginx/admin-guide/web-server/reverse-proxy/
But I could not figure out, how to use the current host name to derive the backend URL.
Read more here: Source link
