<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"><base href="x-msg://2/"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Check against req.http.Host<div><br></div><div>In vcl_recv:</div><div><br></div><div><div>     if(req.http.Host ~ "8.8.8.8") {</div><div>         error 750;</div><div>     }</div><div><br></div><div>-Travis Crowder</div><div><br></div><div><div>On Jul 27, 2013, at 3:48 PM, Puneet <<a href="mailto:puneet.arora@insticator.com">puneet.arora@insticator.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div lang="EN-US" link="#0563C1" vlink="#954F72" style="font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div class="WordSection1" style="page: WordSection1; "><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; "><span style="font-size: 10pt; font-family: Arial, sans-serif; background-color: white; ">Hi all,<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; "><span style="font-size: 10pt; font-family: Arial, sans-serif; "><br><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; ">I want to stop the users accessing my website via IP address.</span><br><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; ">I am using varnish as cache.</span><br><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; ">I have the following code in place but it is not working.</span><br><br><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; ">In vcl_recv() {</span><br><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; ">     if(req.url ~ "XX.XX.XXX.XXX") {</span><br><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; ">     error 750 "Moved Permanently";</span><br><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; ">  } }<span class="apple-converted-space"> </span></span><br><br><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; ">And in vcl_error()</span><br><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; ">sub vcl_error {</span><br><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; ">    if (obj.status == 750) {</span><br><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; ">    set req.http.X-REDIRURL = regsub(req.url,"https?://[^/$]+", "</span></span><a href="http://www.linkedin.com/redirect?url=http%3A%2F%2Fmywebsite%2Ecom&urlhash=5qRF&_t=tracking_anet" target="blank" style="color: rgb(149, 79, 114); text-decoration: underline; "><span style="font-size: 10pt; font-family: Arial, sans-serif; color: rgb(0, 102, 153); border: 1pt none windowtext; padding: 0in; background-color: white; text-decoration: none; background-position: initial initial; background-repeat: initial initial; ">http://mywebsite.com</span></a><span style="font-size: 10pt; font-family: Arial, sans-serif; background-color: white; ">");</span><span style="font-size: 10pt; font-family: Arial, sans-serif; "><br><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; ">    set obj.http.Location = req.http.X-REDIRURL;</span><br><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; ">    set obj.status = 301;</span><br><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; ">    unset req.http.X-REDIRURL;</span><br><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; ">    return(deliver);</span><br><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; ">}</span><br><br><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; ">But this does not redirect the user to the website, instead it delivers the page.</span><br><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; ">Can anyone tell what I am missing?<o:p></o:p></span></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; "><span style="font-size: 10pt; font-family: Arial, sans-serif; background-color: white; "><o:p> </o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; "><span style="font-size: 10pt; font-family: Arial, sans-serif; background-color: white; ">Thanks<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; "><span style="font-size: 10pt; font-family: Arial, sans-serif; background-color: white; ">Puneet</span><o:p></o:p></div></div>_______________________________________________<br>varnish-misc mailing list<br><a href="mailto:varnish-misc@varnish-cache.org" style="color: rgb(149, 79, 114); text-decoration: underline; ">varnish-misc@varnish-cache.org</a><br><a href="https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc" style="color: rgb(149, 79, 114); text-decoration: underline; ">https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc</a></div></blockquote></div><br></div></body></html>