nginx 拒绝下载和热链接图像

nginx deny download and hotlinking images

我在 Windows Server 2012 R2 上使用 Nginx 1.8。我正在网站上发布实时股票图表软件快照。我只使用基本的 html。 我的目标是停止图片上的热链接,也停止下载它们。 我也试过 IIS Apache 无法停止盗链。 我尝试了以下代码来停止盗链并获得成功。

location ~ .(jpg|jpeg|png|gif)$ {
     valid_referers blocked example.com www.example.com;
     if ($invalid_referer) {
        rewrite (.*)\.(jpg|jpeg|png|gif)$ http://abc.example.com/banned-stamp-clipart.png;
    }
}
location /html/images/ {

  ## drop rest of the world
  deny    all;
}

但是如何停止从IDM等下载管理器下载图片,路径例如http://www.example.com/images/abc.png

您无法阻止图片下载,因为要在浏览器中显示它们,如果用户决定下载,则需要下载它们 - he/she 无论如何都会这样做,或者只是截图。

你只能让它变得更难。例如 - 使用 X-Accel-Redirect 和 server-side 脚本,该脚本发出 one-time 令牌用于图像查看,这些令牌在 html 命中时生成并在浏览器下载图像时过期(也在那里检查引荐来源网址)。

图像可以分成几个部分,这样更难使用'as-is'(而且你自己也更难处理)

它们也可以从浏览器缓存中获取,您可以尝试添加 no-cache headers,但这看起来不是一个好主意。