<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Hi Richard,<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>I am able to do have the desired functionality.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>I was missing a piece. The issue is resolved.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Thanks<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Puneet<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><b><span style='font-size:11.0pt;font-family:"Calibri","sans-serif"'>From:</span></b><span style='font-size:11.0pt;font-family:"Calibri","sans-serif"'> varnish-misc-bounces+puneet.arora=insticator.com@varnish-cache.org [mailto:varnish-misc-bounces+puneet.arora=insticator.com@varnish-cache.org] <b>On Behalf Of </b>Lane, Richard<br><b>Sent:</b> Monday, July 29, 2013 8:30 AM<br><b>To:</b> varnish-misc@varnish-cache.org<br><b>Subject:</b> Re: varnish-misc Digest, Vol 88, Issue 17<o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal>I am not sure if it is my email but it looks like you are passing HTML in the REDIRECT URL.<o:p></o:p></p><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>The REDIRECT URL should be just a URL. Try a simple URL like <a href="http://www.yahoo.com">http://www.yahoo.com</a> first. Then work on your regsub statement to set the right URL.<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div></div><div><p class=MsoNormal style='margin-bottom:12.0pt'><o:p> </o:p></p><div><p class=MsoNormal>On Sat, Jul 27, 2013 at 9:38 PM, <<a href="mailto:varnish-misc-request@varnish-cache.org" target="_blank">varnish-misc-request@varnish-cache.org</a>> wrote:<o:p></o:p></p><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in'><p class=MsoNormal>Send varnish-misc mailing list submissions to<br>        <a href="mailto:varnish-misc@varnish-cache.org">varnish-misc@varnish-cache.org</a><br><br>To subscribe or unsubscribe via the World Wide Web, visit<br>        <a href="https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc" target="_blank">https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc</a><br>or, via email, send a message with subject or body 'help' to<br>        <a href="mailto:varnish-misc-request@varnish-cache.org">varnish-misc-request@varnish-cache.org</a><br><br>You can reach the person managing the list at<br>        <a href="mailto:varnish-misc-owner@varnish-cache.org">varnish-misc-owner@varnish-cache.org</a><br><br>When replying, please edit your Subject line so it is more specific<br>than "Re: Contents of varnish-misc digest..."<br><br><br>Today's Topics:<br><br>   1. Re: Stop users accessing website via IP address<br>      (Hugo Cisneiros (Eitch))<br>   2. Re: Stop users accessing website via IP address (Travis Crowder)<br>   3. RE: Stop users accessing website via IP address (Puneet)<br><br><br>----------------------------------------------------------------------<br><br>Message: 1<br>Date: Sat, 27 Jul 2013 18:28:57 -0300<br>From: "Hugo Cisneiros (Eitch)" <<a href="mailto:hugo.cisneiros@gmail.com">hugo.cisneiros@gmail.com</a>><br>To: "<a href="mailto:varnish-misc@varnish-cache.org">varnish-misc@varnish-cache.org</a>" <<a href="mailto:varnish-misc@varnish-cache.org">varnish-misc@varnish-cache.org</a>><br>Subject: Re: Stop users accessing website via IP address<br>Message-ID:<br>        <CA+KACLkCCfpK2XmM4-vaxOW2b=<a href="mailto:XBL-nbgadgt7FE3XejfWA6cw@mail.gmail.com">XBL-nbgadgt7FE3XejfWA6cw@mail.gmail.com</a>><br>Content-Type: text/plain; charset="iso-8859-1"<br><br>On Sat, Jul 27, 2013 at 5:48 PM, Puneet <<a href="mailto:puneet.arora@insticator.com">puneet.arora@insticator.com</a>> wrote:<br><br>> I want to stop the users accessing my website via IP address.<br>><br>> I am using varnish as cache.<br>> I have the following code in place but it is not working.<br>><br>> In vcl_recv() {<br>>      if(req.url ~ "XX.XX.XXX.XXX") {<br>>      error 750 "Moved Permanently";<br>>   } }<br>><br><br>In vcl_recv, you're comparting the IP address with the request URL<br>(req.url), which is wrong. You should compare with client.ip, as it<br>represents the user's IP address.<br><br>Anyway, a much better approach in my opinion is the code:<br><br># list of forbidden ips<br>acl forbidden {<br>  "192.168.0.1",<br>  "192.168.0.2",<br>  "XXX.XXX.XXX.XXX"<br>}<br><br>sub vcl_recv {<br>  if (client.ip ~ forbidden) {<br>    error 301 "<a href="http://mywebsite.com" target="_blank">http://mywebsite.com</a>";<br>  }<br>}<br><br>sub vcl_error {<br>  set obj.http.Content-Type = "text/html; charset=utf-8";<br>  set obj.http.Retry-After = "5";<br><br>  # we deal with redirects here<br>  if (obj.status == 301) {<br>    set obj.http.Location = obj.response;<br>    set obj.response = "Moved Temporarily";<br>    return (deliver);<br>  }<br><br>  if (obj.status == 301){<br>    set obj.http.Location = obj.response;<br>    set obj.response = "Moved Permanently";<br>    return (deliver);<br>  }<br>}<br><br>This way you can update the ACL to multiple IP addresses and they'll be all<br>redirected to <a href="http://mywebsite.com" target="_blank">mywebsite.com</a>.<br><br>--<br>[]'s<br>Hugo<br><a href="http://www.devin.com.br" target="_blank">www.devin.com.br</a><br>-------------- next part --------------<br>An HTML attachment was scrubbed...<br>URL: <<a href="https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20130727/8ceb19b3/attachment-0001.html" target="_blank">https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20130727/8ceb19b3/attachment-0001.html</a>><br><br>------------------------------<br><br>Message: 2<br>Date: Sat, 27 Jul 2013 18:53:11 -0500<br>From: Travis Crowder <<a href="mailto:travis.crowder@spechal.com">travis.crowder@spechal.com</a>><br>To: Puneet <<a href="mailto:puneet.arora@insticator.com">puneet.arora@insticator.com</a>><br>Cc: <a href="mailto:varnish-misc@varnish-cache.org">varnish-misc@varnish-cache.org</a><br>Subject: Re: Stop users accessing website via IP address<br>Message-ID: <<a href="mailto:A89915AA-A7FE-432D-90CD-E8B6BF12A105@spechal.com">A89915AA-A7FE-432D-90CD-E8B6BF12A105@spechal.com</a>><br>Content-Type: text/plain; charset="us-ascii"<br><br>Check against req.http.Host<br><br>In vcl_recv:<br><br>     if(req.http.Host ~ "8.8.8.8") {<br>         error 750;<br>     }<br><br>-Travis Crowder<br><br>On Jul 27, 2013, at 3:48 PM, Puneet <<a href="mailto:puneet.arora@insticator.com">puneet.arora@insticator.com</a>> wrote:<br><br>> Hi all,<br>><br>> I want to stop the users accessing my website via IP address.<br>> I am using varnish as cache.<br>> I have the following code in place but it is not working.<br>><br>> In vcl_recv() {<br>>      if(req.url ~ "XX.XX.XXX.XXX") {<br>>      error 750 "Moved Permanently";<br>>   } }<br>><br>> And in vcl_error()<br>> sub vcl_error {<br>>     if (obj.status == 750) {<br>>     set req.http.X-REDIRURL = regsub(req.url,"https?://[^/$]+", "<a href="http://mywebsite.com" target="_blank">http://mywebsite.com</a>");<br>>     set obj.http.Location = req.http.X-REDIRURL;<br>>     set obj.status = 301;<br>>     unset req.http.X-REDIRURL;<br>>     return(deliver);<br>> }<br>><br>> But this does not redirect the user to the website, instead it delivers the page.<br>> Can anyone tell what I am missing?<br>><br>> Thanks<br>> Puneet<br>> _______________________________________________<br>> varnish-misc mailing list<br>> <a href="mailto:varnish-misc@varnish-cache.org">varnish-misc@varnish-cache.org</a><br>> <a href="https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc" target="_blank">https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc</a><br><br>-------------- next part --------------<br>An HTML attachment was scrubbed...<br>URL: <<a href="https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20130727/da02d31d/attachment-0001.html" target="_blank">https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20130727/da02d31d/attachment-0001.html</a>><br><br>------------------------------<br><br>Message: 3<br>Date: Sat, 27 Jul 2013 22:38:24 -0400<br>From: Puneet <<a href="mailto:puneet.arora@insticator.com">puneet.arora@insticator.com</a>><br>To: "'Travis Crowder'" <<a href="mailto:travis.crowder@spechal.com">travis.crowder@spechal.com</a>><br>Cc: <a href="mailto:varnish-misc@varnish-cache.org">varnish-misc@varnish-cache.org</a><br>Subject: RE: Stop users accessing website via IP address<br>Message-ID: <005701ce8b3b$88e6ee10$9ab4ca30$@<a href="http://insticator.com" target="_blank">insticator.com</a>><br>Content-Type: text/plain; charset="us-ascii"<br><br>HI Travis,<br><br><br><br>Thanks for the reply.<br><br>I think that should work.<br><br><br><br>Just one question.<br><br>In sub vcl_error() should I also change the<br><br><br><br>set req.http.X-REDIRURL = regsub(req.url,"https?://[^/$]+", "<br><<a href="http://www.linkedin.com/redirect?url=http%3A%2F%2Fmywebsite%2Ecom&urlhash=5qRF&_t=tracking_anet" target="_blank">http://www.linkedin.com/redirect?url=http%3A%2F%2Fmywebsite%2Ecom&urlhash=5<br>qRF&_t=tracking_anet</a>> <a href="http://mywebsite.com" target="_blank">http://mywebsite.com</a>");<br><br>TO : --><br><br>set req.http.X-REDIRURL = regsub(req.http.host,"https?://[^/$]+", "<br><<a href="http://www.linkedin.com/redirect?url=http%3A%2F%2Fmywebsite%2Ecom&urlhash=5qRF&_t=tracking_anet" target="_blank">http://www.linkedin.com/redirect?url=http%3A%2F%2Fmywebsite%2Ecom&urlhash=5<br>qRF&_t=tracking_anet</a>> <a href="http://mywebsite.com" target="_blank">http://mywebsite.com</a>");<br><br>?<br><br><br><br>Because when replace req.url with req.http.host, It again stops working.<br><br>And If I don't do it, the bowser gives an error "Too many redirects"<br><br><br><br>Thanks<br><br>Puneet<br><br><br><br>From: Travis Crowder [mailto:<a href="mailto:travis.crowder@spechal.com">travis.crowder@spechal.com</a>]<br>Sent: Saturday, July 27, 2013 7:53 PM<br>To: Puneet<br>Cc: <a href="mailto:varnish-misc@varnish-cache.org">varnish-misc@varnish-cache.org</a><br>Subject: Re: Stop users accessing website via IP address<br><br><br><br>Check against req.http.Host<br><br><br><br>In vcl_recv:<br><br><br><br>     if(req.http.Host ~ "8.8.8.8") {<br><br>         error 750;<br><br>     }<br><br><br><br>-Travis Crowder<br><br><br><br>On Jul 27, 2013, at 3:48 PM, Puneet <<a href="mailto:puneet.arora@insticator.com">puneet.arora@insticator.com</a><br><mailto:<a href="mailto:puneet.arora@insticator.com">puneet.arora@insticator.com</a>> > wrote:<br><br><br><br><br><br>Hi all,<br><br><br>I want to stop the users accessing my website via IP address.<br>I am using varnish as cache.<br>I have the following code in place but it is not working.<br><br>In vcl_recv() {<br>     if(req.url ~ "XX.XX.XXX.XXX") {<br>     error 750 "Moved Permanently";<br>  } }<br><br>And in vcl_error()<br>sub vcl_error {<br>    if (obj.status == 750) {<br>    set req.http.X-REDIRURL = regsub(req.url,"https?://[^/$]+", "<br><<a href="http://www.linkedin.com/redirect?url=http%3A%2F%2Fmywebsite%2Ecom&urlhash=5qRF&_t=tracking_anet" target="_blank">http://www.linkedin.com/redirect?url=http%3A%2F%2Fmywebsite%2Ecom&urlhash=5<br>qRF&_t=tracking_anet</a>> <a href="http://mywebsite.com" target="_blank">http://mywebsite.com</a>");<br>    set obj.http.Location = req.http.X-REDIRURL;<br>    set obj.status = 301;<br>    unset req.http.X-REDIRURL;<br>    return(deliver);<br>}<br><br>But this does not redirect the user to the website, instead it delivers the<br>page.<br>Can anyone tell what I am missing?<br><br><br><br>Thanks<br><br>Puneet<br><br>_______________________________________________<br>varnish-misc mailing list<br> <mailto:<a href="mailto:varnish-misc@varnish-cache.org">varnish-misc@varnish-cache.org</a>> <a href="mailto:varnish-misc@varnish-cache.org">varnish-misc@varnish-cache.org</a><br> <<a href="https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc" target="_blank">https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc</a>><br><a href="https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc" target="_blank">https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc</a><br><br><br><br>-------------- next part --------------<br>An HTML attachment was scrubbed...<br>URL: <<a href="https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20130727/21c9f677/attachment.html" target="_blank">https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20130727/21c9f677/attachment.html</a>><br><br>------------------------------<br><br>_______________________________________________<br>varnish-misc mailing list<br><a href="mailto:varnish-misc@varnish-cache.org">varnish-misc@varnish-cache.org</a><br><a href="https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc" target="_blank">https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc</a><br><br>End of varnish-misc Digest, Vol 88, Issue 17<br>********************************************<o:p></o:p></p></blockquote></div><p class=MsoNormal><o:p> </o:p></p></div></div></body></html>