热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

匿名化Amazon公共URL,使用Nginx上的脚本进行解码-AnonymizeAmazonpublicURL,decodeusingascriptonNginx

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的逻辑。

enter image description here

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


1  

This is an answer to the updated question:

这是对更新后问题的回答:

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请求。必须有一种方法来解码它。

Nginx would make a request to a script, e.g., either through proxy_pass or fastcgi_pass et al.

Nginx会向脚本发出请求,例如通过proxy_pass或fastcgi_pass等。

The script could decode the URL and provide the actual URL through a Location HTTP Response Header with a 302 Found HTTP Status.

该脚本可以解码URL并通过具有302 Found HTTP Status的Location HTTP Response Header提供实际的URL。

Nginx would then have the decoded URL stored in the $upstream_http_location variable. It could subsequently be used in another proxy_pass et al within a named location @named, to which you could redirect the processing of the original request from the user through error_page 302 = @named.

然后,Nginx将解码的URL存储在$ upstream_http_location变量中。它随后可以在命名位置@named内的另一个proxy_pass等中使用,您可以通过error_page 302 = @named将用户的原始请求的处理重定向到该位置。

In all, each user request would be processed twice within nginx, but it'll all be transparent to the user -- they simply receive the resource through the original URL, with all redirects being done internally within nginx.

总之,每个用户请求将在nginx中处理两次,但它对用户都是透明的 - 他们只是通过原始URL接收资源,所有重定向都在nginx内部完成。

#2


1  

Define Anonymize for a URL? You can use any of the same methods as URL shortners such as http://bitly.com. But that is not truely anonymous since there is a definite mapping between the shortened URL and the target public url. If you make this per user based there is still a mapping but it is user based.

为URL定义匿名?您可以使用任何与URL缩短程序相同的方法,例如http://bitly.com。但这不是真正的匿名,因为缩短的URL和目标公共URL之间存在明确的映射。如果您基于每个用户进行此操作,则仍然存在映射,但它是基于用户的。

Looks like what you are suggesting is a variation on the above scheme where instead of sending the user to the target URL via a redirect you want the your server to actually fetch the content and return to the user. You need to be aware of the linked content in the public URL such as style sheets and images and adjust them accordingly. Many of the standard proxies has this kind of functionality built in. Also take a look at

看起来您所建议的是上述方案的变体,而不是通过重定向将用户发送到目标URL,您希望服务器实际获取内容并返回给用户。您需要了解公共URL中的链接内容,例如样式表和图像,并相应地进行调整。许多标准代理都内置了这种功能。另外请看一下

https://github.com/jenssegers/php-proxy

http://search.cpan.org/~book/HTTP-Proxy-0.304/lib/HTTP/Proxy.pm.

If you are planning to build your own these can serve as a base.

如果您打算自己建造这些可以作为基础。

#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标头。


推荐阅读
  • 本文详细解析了JavaScript中相称性推断的知识点,包括严厉相称和宽松相称的区别,以及范例转换的规则。针对不同类型的范例值,如差别范例值、统一类的原始范例值和统一类的复合范例值,都给出了具体的比较方法。对于宽松相称的情况,也解释了原始范例值和对象之间的比较规则。通过本文的学习,读者可以更好地理解JavaScript中相称性推断的概念和应用。 ... [详细]
  • 在Android开发中,使用Picasso库可以实现对网络图片的等比例缩放。本文介绍了使用Picasso库进行图片缩放的方法,并提供了具体的代码实现。通过获取图片的宽高,计算目标宽度和高度,并创建新图实现等比例缩放。 ... [详细]
  • Java实战之电影在线观看系统的实现
    本文介绍了Java实战之电影在线观看系统的实现过程。首先对项目进行了简述,然后展示了系统的效果图。接着介绍了系统的核心代码,包括后台用户管理控制器、电影管理控制器和前台电影控制器。最后对项目的环境配置和使用的技术进行了说明,包括JSP、Spring、SpringMVC、MyBatis、html、css、JavaScript、JQuery、Ajax、layui和maven等。 ... [详细]
  • 原文地址:https:www.cnblogs.combaoyipSpringBoot_YML.html1.在springboot中,有两种配置文件,一种 ... [详细]
  • Python瓦片图下载、合并、绘图、标记的代码示例
    本文提供了Python瓦片图下载、合并、绘图、标记的代码示例,包括下载代码、多线程下载、图像处理等功能。通过参考geoserver,使用PIL、cv2、numpy、gdal、osr等库实现了瓦片图的下载、合并、绘图和标记功能。代码示例详细介绍了各个功能的实现方法,供读者参考使用。 ... [详细]
  • 使用正则表达式爬取36Kr网站首页新闻的操作步骤和代码示例
    本文介绍了使用正则表达式来爬取36Kr网站首页所有新闻的操作步骤和代码示例。通过访问网站、查找关键词、编写代码等步骤,可以获取到网站首页的新闻数据。代码示例使用Python编写,并使用正则表达式来提取所需的数据。详细的操作步骤和代码示例可以参考本文内容。 ... [详细]
  • 在springmvc框架中,前台ajax调用方法,对图片批量下载,如何弹出提示保存位置选框?Controller方法 ... [详细]
  • 解决nginx启动报错epoll_wait() reported that client prematurely closed connection的方法
    本文介绍了解决nginx启动报错epoll_wait() reported that client prematurely closed connection的方法,包括检查location配置是否正确、pass_proxy是否需要加“/”等。同时,还介绍了修改nginx的error.log日志级别为debug,以便查看详细日志信息。 ... [详细]
  • 本文介绍了在开发Android新闻App时,搭建本地服务器的步骤。通过使用XAMPP软件,可以一键式搭建起开发环境,包括Apache、MySQL、PHP、PERL。在本地服务器上新建数据库和表,并设置相应的属性。最后,给出了创建new表的SQL语句。这个教程适合初学者参考。 ... [详细]
  • 这是原文链接:sendingformdata许多情况下,我们使用表单发送数据到服务器。服务器处理数据并返回响应给用户。这看起来很简单,但是 ... [详细]
  • 生成对抗式网络GAN及其衍生CGAN、DCGAN、WGAN、LSGAN、BEGAN介绍
    一、GAN原理介绍学习GAN的第一篇论文当然由是IanGoodfellow于2014年发表的GenerativeAdversarialNetworks(论文下载链接arxiv:[h ... [详细]
  • 欢乐的票圈重构之旅——RecyclerView的头尾布局增加
    项目重构的Git地址:https:github.comrazerdpFriendCircletreemain-dev项目同步更新的文集:http:www.jianshu.comno ... [详细]
  • 本文介绍了响应式页面的概念和实现方式,包括针对不同终端制作特定页面和制作一个页面适应不同终端的显示。分析了两种实现方式的优缺点,提出了选择方案的建议。同时,对于响应式页面的需求和背景进行了讨论,解释了为什么需要响应式页面。 ... [详细]
  • 使用圣杯布局模式实现网站首页的内容布局
    本文介绍了使用圣杯布局模式实现网站首页的内容布局的方法,包括HTML部分代码和实例。同时还提供了公司新闻、最新产品、关于我们、联系我们等页面的布局示例。商品展示区包括了车里子和农家生态土鸡蛋等产品的价格信息。 ... [详细]
  • .NetCoreWebApi生成Swagger接口文档的使用方法
    本文介绍了使用.NetCoreWebApi生成Swagger接口文档的方法,并详细说明了Swagger的定义和功能。通过使用Swagger,可以实现接口和服务的可视化,方便测试人员进行接口测试。同时,还提供了Github链接和具体的步骤,包括创建WebApi工程、引入swagger的包、配置XML文档文件和跨域处理。通过本文,读者可以了解到如何使用Swagger生成接口文档,并加深对Swagger的理解。 ... [详细]
author-avatar
郭建将_683
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有