作者:郭建将_683 | 来源:互联网 | 2023-09-24 10:10
IhavebeenwonderingifitspossibletoanonymizepublicURL.Whenusermakesarequestwiththisa
I have been wondering if its possible to anonymize public URL. When user makes a request with this anonymized public URL, let Nginx decode, fetch and serve the URL.
我一直在想是否可以匿名公共URL。当用户使用此匿名公共URL发出请求时,让Nginx解码,获取并提供URL。
Example
Public URL http://amazon.server.com/location/file.html
公共URL http://amazon.server.com/location/file.html
Anonymized URL https://amazon.server.com/09872340-932872389-390643289/983724.html
匿名网址https://amazon.server.com/09872340-932872389-390643289/983724.html
Nginx decodes 09872340-932872389-390643289/983724.html
to location/file.html
Nginx将09872340-932872389-390643289 / 983724.html解码为location / file.html
Added image below for further clarification. Nginx has a reverse logic to decode, whereas Remote Server
has the logic to Anonymize URL.
添加了下面的图片以进一步说明。 Nginx具有解码的反向逻辑,而远程服务器具有匿名URL的逻辑。
Question All I need to know is how would Nginx decode anonymized URL? Nginx got anonymized URL request. There has to be a way to decode it.
问题我需要知道的是Nginx如何解码匿名URL? Nginx获得了匿名URL请求。必须有一种方法来解码它。
3 个解决方案
1
I think what you want to do here is somewhat similar to another question I've answered in the past, where for each request by the client, you effectively want to make two requests to two different upstreams under the hood (first one to an upstream capable of decoding the URL, second one to actually fetch said decoded URL), but, of course, only return one result.
我想你想在这里做的有点类似于我过去回答的另一个问题,对于客户的每个请求,你实际上想要向引擎盖下的两个不同的上游发出两个请求(第一个到上游)能够解码URL,第二个能够实际获取所述解码的URL),但是,当然,只返回一个结果。
https://serverfault.com/questions/202011/nginx-and-2-upstreams/485044#485044
As mentioned on serverfault, you could use error_page
to process another request, after the first one is complete. You could then use $upstream_http_
to make the subsequent request based on the original one, for example, using $upstream_http_location
.
正如在serverfault上提到的,在第一个请求完成后,您可以使用error_page处理另一个请求。然后,您可以使用$ upstream_http_根据原始请求生成后续请求,例如,使用$ upstream_http_location。
You might also want to look into X-Accel-Redirect
header, introduced in this context at proxy_ignore_headers
.
您可能还想查看在此上下文中在proxy_ignore_headers中引入的X-Accel-Redirect标头。