<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">I guess I am confused as to why you need the rewrite.<div><br></div><div>sub vcl_recv {</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>if(req.http.Host ~ "8.8.8.8") {
error 750;
}</div><div>}</div><div><br></div><div>sub vcl_error {</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>if(obj.status == 750) { </div><div><span class="Apple-tab-span" style="white-space:pre"> </span> set obj.http.Location = "<a href="http://google.com/login">http://google.com/login</a>"; </div><div><span class="Apple-tab-span" style="white-space:pre"> </span> set obj.status = 302; </div><div><span class="Apple-tab-span" style="white-space:pre"> </span> return (deliver); </div><div><span class="Apple-tab-span" style="white-space:pre"> </span>}</div><div>}</div><div><br><div><div>On Jul 27, 2013, at 10:03 PM, Travis Crowder <<a href="mailto:travis.crowder@spechal.com">travis.crowder@spechal.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><meta http-equiv="Content-Type" content="text/html charset=windows-1252"><base href="x-msg://2/"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Your regular expression is malformed and you don't do any capturing or replacement in the regsub function so I am not sure what you're trying to accomplish there.<div><br></div><div>Can you elaborate on what you're trying set this header's value to?</div><div><br></div><div>-Travis Crowder</div><div><br></div><div><br><div><div>On Jul 27, 2013, at 9:38 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="blue" vlink="purple" 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: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125); ">HI Travis,<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125); "> </span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125); ">Thanks for the reply.<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125); ">I think that should work.<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125); "> </span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125); ">Just one question.<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125); ">In sub vcl_error() should I also change the<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 10pt; font-family: Arial, sans-serif; background-color: white; background-position: initial initial; background-repeat: initial initial; "><o:p> </o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 10pt; font-family: Arial, sans-serif; background-color: white; background-position: initial initial; background-repeat: initial initial; ">set req.http.X-REDIRURL = regsub(<b>req.url</b>,"https?://[^/$]+", "</span><span style="font-size: 11pt; font-family: Calibri, sans-serif; "><a href="http://www.linkedin.com/redirect?url=http%3A%2F%2Fmywebsite%2Ecom&urlhash=5qRF&_t=tracking_anet" target="blank" style="color: purple; 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><span style="font-size: 10pt; font-family: Arial, sans-serif; background-color: white; background-position: initial initial; background-repeat: initial initial; ">");<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 10pt; font-family: Arial, sans-serif; background-color: white; background-position: initial initial; background-repeat: initial initial; ">TO :<span class="Apple-converted-space"> </span></span><span style="font-size: 10pt; font-family: Wingdings; background-color: white; background-position: initial initial; background-repeat: initial initial; ">à</span><span style="font-size: 10pt; font-family: Arial, sans-serif; background-color: white; background-position: initial initial; background-repeat: initial initial; "><o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 10pt; font-family: Arial, sans-serif; background-color: white; background-position: initial initial; background-repeat: initial initial; ">set req.http.X-REDIRURL = regsub(<b>req.http.host</b>,"https?://[^/$]+", "</span><span style="font-size: 11pt; font-family: Calibri, sans-serif; "><a href="http://www.linkedin.com/redirect?url=http%3A%2F%2Fmywebsite%2Ecom&urlhash=5qRF&_t=tracking_anet" target="blank" style="color: purple; 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><span style="font-size: 10pt; font-family: Arial, sans-serif; background-color: white; background-position: initial initial; background-repeat: initial initial; ">");<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125); ">?<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125); "> </span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125); ">Because when<span class="Apple-converted-space"> </span><b>replace req.url with req.http.host</b>, It again stops working.<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125); ">And<span class="Apple-converted-space"> </span><b>If I don’t do it</b>, the bowser gives an error<span class="Apple-converted-space"> </span><b>“Too many redirects”<o:p></o:p></b></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125); "> </span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125); ">Thanks<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125); ">Puneet<o:p></o:p></span></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125); "> </span></div><div><div style="border-style: solid none none; border-top-width: 1pt; border-top-color: rgb(225, 225, 225); padding: 3pt 0in 0in; "><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><b><span style="font-size: 11pt; font-family: Calibri, sans-serif; ">From:</span></b><span style="font-size: 11pt; font-family: Calibri, sans-serif; "><span class="Apple-converted-space"> </span>Travis Crowder [mailto:travis.crowder@<a href="http://spechal.com/">spechal.com</a>]<span class="Apple-converted-space"> </span><br><b>Sent:</b><span class="Apple-converted-space"> </span>Saturday, July 27, 2013 7:53 PM<br><b>To:</b><span class="Apple-converted-space"> </span>Puneet<br><b>Cc:</b><span class="Apple-converted-space"> </span><a href="mailto:varnish-misc@varnish-cache.org">varnish-misc@varnish-cache.org</a><br><b>Subject:</b><span class="Apple-converted-space"> </span>Re: Stop users accessing website via IP address<o:p></o:p></span></div></div></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><o:p> </o:p></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; ">Check against req.http.Host<o:p></o:p></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><o:p> </o:p></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; ">In vcl_recv:<o:p></o:p></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><o:p> </o:p></div></div><div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "> if(req.http.Host ~ "8.8.8.8") {<o:p></o:p></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "> error 750;<o:p></o:p></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "> }<o:p></o:p></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><o:p> </o:p></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; ">-Travis Crowder<o:p></o:p></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><o:p> </o:p></div></div><div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; ">On Jul 27, 2013, at 3:48 PM, Puneet <<a href="mailto:puneet.arora@insticator.com" style="color: purple; text-decoration: underline; ">puneet.arora@insticator.com</a>> wrote:<o:p></o:p></div></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><br><br><o:p></o:p></div><blockquote style="margin-top: 5pt; margin-bottom: 5pt; "><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 10pt; font-family: Arial, sans-serif; background-color: white; background-position: initial initial; background-repeat: initial initial; ">Hi all,</span><span style="font-size: 11pt; font-family: Calibri, sans-serif; "><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', 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><span style="font-size: 11pt; font-family: Calibri, sans-serif; "><a href="http://www.linkedin.com/redirect?url=http%3A%2F%2Fmywebsite%2Ecom&urlhash=5qRF&_t=tracking_anet" target="blank" style="color: purple; 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><span style="font-size: 10pt; font-family: Arial, sans-serif; background-color: white; background-position: initial initial; background-repeat: initial initial; ">");</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?</span></span><span style="font-size: 11pt; font-family: Calibri, sans-serif; "><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 10pt; font-family: Arial, sans-serif; background-color: white; background-position: initial initial; background-repeat: initial initial; "> </span><span style="font-size: 11pt; font-family: Calibri, sans-serif; "><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 10pt; font-family: Arial, sans-serif; background-color: white; background-position: initial initial; background-repeat: initial initial; ">Thanks</span><span style="font-size: 11pt; font-family: Calibri, sans-serif; "><o:p></o:p></span></div></div><div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 10pt; font-family: Arial, sans-serif; background-color: white; background-position: initial initial; background-repeat: initial initial; ">Puneet</span><span style="font-size: 11pt; font-family: Calibri, sans-serif; "><o:p></o:p></span></div></div><div style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 13.5pt; font-family: Helvetica, sans-serif; ">_______________________________________________<br>varnish-misc mailing list<br><a href="mailto:varnish-misc@varnish-cache.org" style="color: purple; text-decoration: underline; "><span style="color: rgb(149, 79, 114); ">varnish-misc@varnish-cache.org</span></a><br><a href="https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc" style="color: purple; text-decoration: underline; "><span style="color: rgb(149, 79, 114); ">https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc</span></a><o:p></o:p></span></div></blockquote></div><p class="MsoNormal" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif; "></p></div></div></div></blockquote></div><br></div></div>_______________________________________________<br>varnish-misc mailing list<br><a href="mailto:varnish-misc@varnish-cache.org">varnish-misc@varnish-cache.org</a><br>https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc</blockquote></div><br></div></body></html>