<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><span class="Apple-style-span" style="font-family: 'Lucida Grande'; font-size: 10px; "><div class="message" style="word-wrap: break-word; position: relative; background-image: url(file:///Applications/Adium.app/Contents/Resources/Message%20Styles/Smooth%20Operator.AdiumMessageStyle/Contents/Resources/images/bottom_left.png); background-repeat: repeat-y; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: initial; margin-top: 0px; margin-right: -24px; margin-bottom: 0px; margin-left: -41px; text-shadow: rgb(204, 204, 204) 1px 1px 3px; padding-top: 10px; padding-right: 0px; padding-bottom: 10px; padding-left: 56px; min-height: 25px; color: rgb(64, 64, 64); background-position: 0% 100%; "><div class="text" style="word-wrap: break-word; padding-top: 6px; padding-right: 40px; padding-bottom: 6px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; overflow-x: auto; overflow-y: auto; "><font class="Apple-style-span" face="Helvetica" size="3"><span class="Apple-style-span" style="font-size: 12px;"><font class="Apple-style-span" color="#000000">I've set up varnish to handle hot linking, but I have an issue with varnish caching the "hotlink" image for the image request.<div><br></div><div>Here's the relevant part of default.vcl:</div><div><br></div></font>sub vcl_recv {<br style="word-wrap: break-word; "><br style="word-wrap: break-word; "># Add a unique header containing the client address<br style="word-wrap: break-word; ">remove req.http.X-Forwarded-For;<br style="word-wrap: break-word; ">set req.http.X-Forwarded-For = client.ip;</span></font></div><div class="text" style="word-wrap: break-word; padding-top: 6px; padding-right: 40px; padding-bottom: 6px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; overflow-x: auto; overflow-y: auto; "><font class="Apple-style-span" face="Helvetica" size="3"><span class="Apple-style-span" style="font-size: 12px;"> if (req.request == "GET") {<br style="word-wrap: break-word; "> if ( !(req.http.referer ~ "[a-z0-9]+.domain.com|yahoo.|rssbandit.org|newsgator.com|google.|search?q=cache" ) && (req.http.host ~ "^(raw)?images.domain.") && (req.http.referer) ) {<br style="word-wrap: break-word; "> set req.url="<a href="http://images.domain.com/hotlink.gif">http://images.domain.com/hotlink.gif</a>";<br style="word-wrap: break-word; "> pass;<br style="word-wrap: break-word; "> }<br style="word-wrap: break-word; "> lookup;<br style="word-wrap: break-word; "> }<br style="word-wrap: break-word; "><br style="word-wrap: break-word; "> if (req.request == "PURGE") {<br style="word-wrap: break-word; "> purge_url(req.url);<br style="word-wrap: break-word; "> error 200 "OK!!";<br style="word-wrap: break-word; "> }<br style="word-wrap: break-word; ">}</span></font></div><div class="text" style="word-wrap: break-word; padding-top: 6px; padding-right: 40px; padding-bottom: 6px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; overflow-x: auto; overflow-y: auto; "><br></div><div class="text" style="word-wrap: break-word; padding-top: 6px; padding-right: 40px; padding-bottom: 6px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; overflow-x: auto; overflow-y: auto; "><font class="Apple-style-span" face="Helvetica" size="3"><span class="Apple-style-span" style="font-size: 12px;">The problem is this, a user hotlinks <a href="http://images.domain.com/puppy.jpeg">http://images.domain.com/puppy.jpeg</a> and we return hotlink.gif.</span></font></div><div class="text" style="word-wrap: break-word; padding-top: 6px; padding-right: 40px; padding-bottom: 6px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; overflow-x: auto; overflow-y: auto; "><font class="Apple-style-span" face="Helvetica" size="3"><span class="Apple-style-span" style="font-size: 12px;">Now if a user legitimately loads puppy.jpeg he receives the cached copy of hotlink.gif in its place.</span></font></div><div class="text" style="word-wrap: break-word; padding-top: 6px; padding-right: 40px; padding-bottom: 6px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; overflow-x: auto; overflow-y: auto; "><font class="Apple-style-span" face="Helvetica" size="3"><span class="Apple-style-span" style="font-size: 12px;">I though by setting the req.url that the cached file is now hotlink.gif and we haven't even attempted to store puppy.jpeg in the cache.</span></font></div><div class="text" style="word-wrap: break-word; padding-top: 6px; padding-right: 40px; padding-bottom: 6px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; overflow-x: auto; overflow-y: auto; "><font class="Apple-style-span" face="Helvetica" size="3"><span class="Apple-style-span" style="font-size: 12px;">I need to legitimately serve puppy.jpeg even if it's being hotlinked from somewhere.</span></font></div><div class="text" style="word-wrap: break-word; padding-top: 6px; padding-right: 40px; padding-bottom: 6px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; overflow-x: auto; overflow-y: auto; "><font class="Apple-style-span" face="Helvetica" size="3"><span class="Apple-style-span" style="font-size: 12px;">Any help would be appreciated.</span></font></div><div class="text" style="word-wrap: break-word; padding-top: 6px; padding-right: 40px; padding-bottom: 6px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; overflow-x: auto; overflow-y: auto; "><font class="Apple-style-span" face="Helvetica" size="3"><span class="Apple-style-span" style="font-size: 12px;">Thanks</span></font></div><div class="text" style="word-wrap: break-word; padding-top: 6px; padding-right: 40px; padding-bottom: 6px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; overflow-x: auto; overflow-y: auto; "><font class="Apple-style-span" face="Helvetica" size="3"><span class="Apple-style-span" style="font-size: 12px;">Chris</span></font></div></div></span></div></body></html>