我的服务器生成了一个动态图像(http://myserver.com/image/71286cdef.png),并由其他网站上传。此html被嵌入到其他服务器(比如http://www.othersite.com/787878.html)的页面中
<img src='http://myserver.com/image/71286cdef.png'/>如何在我的服务器中检测url (http://www.othersite.com/787878.html)加载图像
http://myserver.com/image/71286cdef.png发布于 2013-04-15 12:13:21
非特定于Ruby :通常情况下,浏览器会将"referer"标头与所有请求一起发送到原始页面上的资源。因此,在生成图像的代码中,您可以检查该标头。
您还可以配置您的服务器来记录referrer标题和其他标准属性(IP,Url,查询参数),如果您需要它只是为了以后的分析。
注意:此标题可能丢失或伪造-没有真正可靠的方法来确认谁请求了该图像。(可能是带有客户端证书的SSL的简称)。
可能来自Dealing With Ruby Vulnerabilities: Check HTTP Referrers的Ruby代码
if (
( request.headers['referer'].nil? ) or
( (request.headers['referer'] =~ %r[^http://#{request.host_with_port}/]).nil? )
)
flash[:notice] = "Incorrect Referer header"
redirect_to :action => 'index'
endhttps://stackoverflow.com/questions/16007482
复制相似问题