Score:0

nginx rewrite and proxy pass

br flag

I want to setup Nginx to rewrite a URL before proxy passing to backend. The URL in question is

/_next/data/Q4tMYXGjDnTfBtYGNUrKu/uk/basic/something/something-else/file.json

What I ideally want is to rewrite the buildID Q4tMYXGjDnTfBtYGNUrKu to what will be in a request header i.e. $http_build_id

So any of these URLs:

/_next/data/Q4tMYXGjDnTfBtYGNUrKu/uk/basic/something/something-else/file.json
/_next/data/Q4tgf3GNUrKu/uk/basic/something/something-else/file.json
/_next/data/TEST/uk/basic/something/something-else/file.json

Would all proxy pass to upstream/backend as: /_next/data/Q4tMYXGjDnTfBtYGNUrKu/uk/basic/something/something-else/file.json Assuming $http_build_id is Q4tMYXGjDnTfBtYGNUrKu

And Nginx would return the results on the original URL that was requested i.e. /_next/data/TEST/uk/basic/something/something-else/file.json

Can anyone help?

suchislife avatar
us flag
See [nginxconfig.io](https://nginxconfig.io)
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.