Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Varnish: Misc

Stop users accessing website via IP address

 

 

Varnish misc RSS feed   Index | Next | Previous | View Threaded


puneet.arora at insticator

Jul 27, 2013, 1:48 PM

Post #1 of 13 (150 views)
Permalink
Stop users accessing website via IP address

Hi all,


I want to stop the users accessing my website via IP address.
I am using varnish as cache.
I have the following code in place but it is not working.

In vcl_recv() {
if(req.url ~ "XX.XX.XXX.XXX") {
error 750 "Moved Permanently";
} }

And in vcl_error()
sub vcl_error {
if (obj.status == 750) {
set req.http.X-REDIRURL = regsub(req.url,"https?://[^/$]+", "
<http://www.linkedin.com/redirect?url=http%3A%2F%2Fmywebsite%2Ecom&urlhash=5
qRF&_t=tracking_anet> http://mywebsite.com");
set obj.http.Location = req.http.X-REDIRURL;
set obj.status = 301;
unset req.http.X-REDIRURL;
return(deliver);
}

But this does not redirect the user to the website, instead it delivers the
page.
Can anyone tell what I am missing?



Thanks

Puneet


smwood4 at gmail

Jul 27, 2013, 2:04 PM

Post #2 of 13 (143 views)
Permalink
Re: Stop users accessing website via IP address [In reply to]

Hello, Puneet. You'll need to do the blocking on the sub vcl_recv and not
sub vcl_error.

Here's an easy VCL config example:

acl forbidden {
"xxx.xxx.xxx.xxx";
"xxx.xxx.xxx.xxx";
}

sub vcl_recv {
# Prevent access from these hosts
if (client.ip ~ forbidden) {
error 403 "Forbidden";
}
}

Let me know if you have any other questions.

On Sat, Jul 27, 2013 at 1:48 PM, Puneet <puneet.arora [at] insticator> wrote:

> Hi all,****
>
>
> I want to stop the users accessing my website via IP address.
> I am using varnish as cache.
> I have the following code in place but it is not working.
>
> In vcl_recv() {
> if(req.url ~ "XX.XX.XXX.XXX") {
> error 750 "Moved Permanently";
> } }
>
> And in vcl_error()
> sub vcl_error {
> if (obj.status == 750) {
> set req.http.X-REDIRURL = regsub(req.url,"https?://[^/$]+", "
> http://mywebsite.com<http://www.linkedin.com/redirect?url=http%3A%2F%2Fmywebsite%2Ecom&urlhash=5qRF&_t=tracking_anet>
> ");
> set obj.http.Location = req.http.X-REDIRURL;
> set obj.status = 301;
> unset req.http.X-REDIRURL;
> return(deliver);
> }
>
> But this does not redirect the user to the website, instead it delivers
> the page.
> Can anyone tell what I am missing?****
>
> ** **
>
> Thanks****
>
> Puneet****
>
> _______________________________________________
> varnish-misc mailing list
> varnish-misc [at] varnish-cache
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
>



--
Stephen Wood
Dev/Ops Engineer
Moz, Inc.
Website: www.heystephenwood.com


puneet.arora at insticator

Jul 27, 2013, 2:15 PM

Post #3 of 13 (143 views)
Permalink
RE: Stop users accessing website via IP address [In reply to]

Hi Stephen,



I think I did not stated the problem correctly.



Let me explain the issue:

Say, my website www.mywebsite.com <http://www.mywebsite.com> is hosted on
IP : 167.123.98.20

Now the Users could type in the IP address i.e. 167.123.98.20 and access my
website as the server is listening at port 80.



Now, if any user does that, I want to redirect the Users to
www.mywebsite.com <http://www.mywebsite.com> .

I don't want any User transaction to be done using 167.123.98.20.



Therefore I had the following code in place.



//If the User access my website using the IP address

vcl_recv() {
if(req.url ~ "167.123.98.20") {
error 750 "Moved Permanently";
} }



Redirect the user to www.mywebsite.com.

sub vcl_error {
if (obj.status == 750) {
set req.http.X-REDIRURL = regsub(req.url,"https?://[^/$]+", "
<http://www.linkedin.com/redirect?url=http%3A%2F%2Fmywebsite%2Ecom&urlhash=5
qRF&_t=tracking_anet> http://mywebsite.com");
set obj.http.Location = req.http.X-REDIRURL;
set obj.status = 301;
unset req.http.X-REDIRURL;
return(deliver);
}



I hope I clarified the issue.



Thanks

Puneet



From: Stephen Wood [mailto:smwood4 [at] gmail]
Sent: Saturday, July 27, 2013 5:05 PM
To: Puneet
Cc: varnish-misc [at] varnish-cache
Subject: Re: Stop users accessing website via IP address



Hello, Puneet. You'll need to do the blocking on the sub vcl_recv and not
sub vcl_error.



Here's an easy VCL config example:



acl forbidden {
"xxx.xxx.xxx.xxx";
"xxx.xxx.xxx.xxx";
}

sub vcl_recv {
# Prevent access from these hosts
if (client.ip ~ forbidden) {
error 403 "Forbidden";
}
}


Let me know if you have any other questions.



On Sat, Jul 27, 2013 at 1:48 PM, Puneet <puneet.arora [at] insticator
<mailto:puneet.arora [at] insticator> > wrote:

Hi all,


I want to stop the users accessing my website via IP address.
I am using varnish as cache.
I have the following code in place but it is not working.

In vcl_recv() {
if(req.url ~ "XX.XX.XXX.XXX") {
error 750 "Moved Permanently";
} }

And in vcl_error()
sub vcl_error {
if (obj.status == 750) {
set req.http.X-REDIRURL = regsub(req.url,"https?://[^/$]+", "
<http://www.linkedin.com/redirect?url=http%3A%2F%2Fmywebsite%2Ecom&urlhash=5
qRF&_t=tracking_anet> http://mywebsite.com");
set obj.http.Location = req.http.X-REDIRURL;
set obj.status = 301;
unset req.http.X-REDIRURL;
return(deliver);
}

But this does not redirect the user to the website, instead it delivers the
page.
Can anyone tell what I am missing?



Thanks

Puneet


_______________________________________________
varnish-misc mailing list
varnish-misc [at] varnish-cache <mailto:varnish-misc [at] varnish-cache>
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc







--

Stephen Wood

Dev/Ops Engineer

Moz, Inc.

Website: www.heystephenwood.com <http://www.heystephenwood.com>


hugo.cisneiros at gmail

Jul 27, 2013, 2:28 PM

Post #4 of 13 (143 views)
Permalink
Re: Stop users accessing website via IP address [In reply to]

On Sat, Jul 27, 2013 at 5:48 PM, Puneet <puneet.arora [at] insticator> wrote:

> I want to stop the users accessing my website via IP address.
>
> I am using varnish as cache.
> I have the following code in place but it is not working.
>
> In vcl_recv() {
> if(req.url ~ "XX.XX.XXX.XXX") {
> error 750 "Moved Permanently";
> } }
>

In vcl_recv, you're comparting the IP address with the request URL
(req.url), which is wrong. You should compare with client.ip, as it
represents the user's IP address.

Anyway, a much better approach in my opinion is the code:

# list of forbidden ips
acl forbidden {
"192.168.0.1",
"192.168.0.2",
"XXX.XXX.XXX.XXX"
}

sub vcl_recv {
if (client.ip ~ forbidden) {
error 301 "http://mywebsite.com";
}
}

sub vcl_error {
set obj.http.Content-Type = "text/html; charset=utf-8";
set obj.http.Retry-After = "5";

# we deal with redirects here
if (obj.status == 301) {
set obj.http.Location = obj.response;
set obj.response = "Moved Temporarily";
return (deliver);
}

if (obj.status == 301){
set obj.http.Location = obj.response;
set obj.response = "Moved Permanently";
return (deliver);
}
}

This way you can update the ACL to multiple IP addresses and they'll be all
redirected to mywebsite.com.

--
[]'s
Hugo
www.devin.com.br


travis.crowder at spechal

Jul 27, 2013, 4:53 PM

Post #5 of 13 (144 views)
Permalink
Re: Stop users accessing website via IP address [In reply to]

Check against req.http.Host

In vcl_recv:

if(req.http.Host ~ "8.8.8.8") {
error 750;
}

-Travis Crowder

On Jul 27, 2013, at 3:48 PM, Puneet <puneet.arora [at] insticator> wrote:

> Hi all,
>
> I want to stop the users accessing my website via IP address.
> I am using varnish as cache.
> I have the following code in place but it is not working.
>
> In vcl_recv() {
> if(req.url ~ "XX.XX.XXX.XXX") {
> error 750 "Moved Permanently";
> } }
>
> And in vcl_error()
> sub vcl_error {
> if (obj.status == 750) {
> set req.http.X-REDIRURL = regsub(req.url,"https?://[^/$]+", "http://mywebsite.com");
> set obj.http.Location = req.http.X-REDIRURL;
> set obj.status = 301;
> unset req.http.X-REDIRURL;
> return(deliver);
> }
>
> But this does not redirect the user to the website, instead it delivers the page.
> Can anyone tell what I am missing?
>
> Thanks
> Puneet
> _______________________________________________
> varnish-misc mailing list
> varnish-misc [at] varnish-cache
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc


puneet.arora at insticator

Jul 27, 2013, 7:38 PM

Post #6 of 13 (137 views)
Permalink
RE: Stop users accessing website via IP address [In reply to]

HI Travis,



Thanks for the reply.

I think that should work.



Just one question.

In sub vcl_error() should I also change the



set req.http.X-REDIRURL = regsub(req.url,"https?://[^/$]+", "
<http://www.linkedin.com/redirect?url=http%3A%2F%2Fmywebsite%2Ecom&urlhash=5
qRF&_t=tracking_anet> http://mywebsite.com");

TO : -->

set req.http.X-REDIRURL = regsub(req.http.host,"https?://[^/$]+", "
<http://www.linkedin.com/redirect?url=http%3A%2F%2Fmywebsite%2Ecom&urlhash=5
qRF&_t=tracking_anet> http://mywebsite.com");

?



Because when replace req.url with req.http.host, It again stops working.

And If I don't do it, the bowser gives an error "Too many redirects"



Thanks

Puneet



From: Travis Crowder [mailto:travis.crowder [at] spechal]
Sent: Saturday, July 27, 2013 7:53 PM
To: Puneet
Cc: varnish-misc [at] varnish-cache
Subject: Re: Stop users accessing website via IP address



Check against req.http.Host



In vcl_recv:



if(req.http.Host ~ "8.8.8.8") {

error 750;

}



-Travis Crowder



On Jul 27, 2013, at 3:48 PM, Puneet <puneet.arora [at] insticator
<mailto:puneet.arora [at] insticator> > wrote:





Hi all,


I want to stop the users accessing my website via IP address.
I am using varnish as cache.
I have the following code in place but it is not working.

In vcl_recv() {
if(req.url ~ "XX.XX.XXX.XXX") {
error 750 "Moved Permanently";
} }

And in vcl_error()
sub vcl_error {
if (obj.status == 750) {
set req.http.X-REDIRURL = regsub(req.url,"https?://[^/$]+", "
<http://www.linkedin.com/redirect?url=http%3A%2F%2Fmywebsite%2Ecom&urlhash=5
qRF&_t=tracking_anet> http://mywebsite.com");
set obj.http.Location = req.http.X-REDIRURL;
set obj.status = 301;
unset req.http.X-REDIRURL;
return(deliver);
}

But this does not redirect the user to the website, instead it delivers the
page.
Can anyone tell what I am missing?



Thanks

Puneet

_______________________________________________
varnish-misc mailing list
<mailto:varnish-misc [at] varnish-cache> varnish-misc [at] varnish-cache
<https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc>
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc


travis.crowder at spechal

Jul 27, 2013, 8:03 PM

Post #7 of 13 (133 views)
Permalink
Re: Stop users accessing website via IP address [In reply to]

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.

Can you elaborate on what you're trying set this header's value to?

-Travis Crowder


On Jul 27, 2013, at 9:38 PM, Puneet <puneet.arora [at] insticator> wrote:

> HI Travis,
>
> Thanks for the reply.
> I think that should work.
>
> Just one question.
> In sub vcl_error() should I also change the
>
> set req.http.X-REDIRURL = regsub(req.url,"https?://[^/$]+", "http://mywebsite.com");
> TO : à
> set req.http.X-REDIRURL = regsub(req.http.host,"https?://[^/$]+", "http://mywebsite.com");
> ?
>
> Because when replace req.url with req.http.host, It again stops working.
> And If I don’t do it, the bowser gives an error “Too many redirects”
>
> Thanks
> Puneet
>
> From: Travis Crowder [mailto:travis.crowder [at] spechal]
> Sent: Saturday, July 27, 2013 7:53 PM
> To: Puneet
> Cc: varnish-misc [at] varnish-cache
> Subject: Re: Stop users accessing website via IP address
>
> Check against req.http.Host
>
> In vcl_recv:
>
> if(req.http.Host ~ "8.8.8.8") {
> error 750;
> }
>
> -Travis Crowder
>
> On Jul 27, 2013, at 3:48 PM, Puneet <puneet.arora [at] insticator> wrote:
>
>
> Hi all,
>
> I want to stop the users accessing my website via IP address.
> I am using varnish as cache.
> I have the following code in place but it is not working.
>
> In vcl_recv() {
> if(req.url ~ "XX.XX.XXX.XXX") {
> error 750 "Moved Permanently";
> } }
>
> And in vcl_error()
> sub vcl_error {
> if (obj.status == 750) {
> set req.http.X-REDIRURL = regsub(req.url,"https?://[^/$]+", "http://mywebsite.com");
> set obj.http.Location = req.http.X-REDIRURL;
> set obj.status = 301;
> unset req.http.X-REDIRURL;
> return(deliver);
> }
>
> But this does not redirect the user to the website, instead it delivers the page.
> Can anyone tell what I am missing?
>
> Thanks
> Puneet
> _______________________________________________
> varnish-misc mailing list
> varnish-misc [at] varnish-cache
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc


puneet.arora at insticator

Jul 27, 2013, 8:13 PM

Post #8 of 13 (132 views)
Permalink
RE: Stop users accessing website via IP address [In reply to]

HI Travis,



I am trying to redirect the user to the location of my website.



For eg. The user enters http://X.X.X.X/login

I want to redirect the user to http://www.mywebsite.com/login



In the regular expression I am replacing the HOST NAME i.e. http://X.X.X.X
with http://www.mywebsite.com.

Therefore, I am just setting the header value to
http://www.mywebsite.com/login

And then in the next line

Set , obj.location to : http://www.mywebsite.com/login



This was what I intended to accomplish.



Thanks

Puneet

From: Travis Crowder [mailto:travis.crowder [at] spechal]
Sent: Saturday, July 27, 2013 11:04 PM
To: Puneet
Cc: varnish-misc [at] varnish-cache
Subject: Re: Stop users accessing website via IP address



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.



Can you elaborate on what you're trying set this header's value to?



-Travis Crowder





On Jul 27, 2013, at 9:38 PM, Puneet <puneet.arora [at] insticator
<mailto:puneet.arora [at] insticator> > wrote:





HI Travis,



Thanks for the reply.

I think that should work.



Just one question.

In sub vcl_error() should I also change the



set req.http.X-REDIRURL = regsub(req.url,"https?://[^/$]+", "
<http://www.linkedin.com/redirect?url=http%3A%2F%2Fmywebsite%2Ecom&urlhash=5
qRF&_t=tracking_anet> http://mywebsite.com");

TO : -->

set req.http.X-REDIRURL = regsub(req.http.host,"https?://[^/$]+", "
<http://www.linkedin.com/redirect?url=http%3A%2F%2Fmywebsite%2Ecom&urlhash=5
qRF&_t=tracking_anet> http://mywebsite.com");

?



Because when replace req.url with req.http.host, It again stops working.

And If I don't do it, the bowser gives an error "Too many redirects"



Thanks

Puneet



From: Travis Crowder [mailto:travis.crowder [at] spechal <http://spechal.com>
]
Sent: Saturday, July 27, 2013 7:53 PM
To: Puneet
Cc: varnish-misc [at] varnish-cache <mailto:varnish-misc [at] varnish-cache>
Subject: Re: Stop users accessing website via IP address



Check against req.http.Host



In vcl_recv:



if(req.http.Host ~ "8.8.8.8") {

error 750;

}



-Travis Crowder



On Jul 27, 2013, at 3:48 PM, Puneet < <mailto:puneet.arora [at] insticator>
puneet.arora [at] insticator> wrote:






Hi all,


I want to stop the users accessing my website via IP address.
I am using varnish as cache.
I have the following code in place but it is not working.

In vcl_recv() {
if(req.url ~ "XX.XX.XXX.XXX") {
error 750 "Moved Permanently";
} }

And in vcl_error()
sub vcl_error {
if (obj.status == 750) {
set req.http.X-REDIRURL = regsub(req.url,"https?://[^/$]+", "
<http://www.linkedin.com/redirect?url=http%3A%2F%2Fmywebsite%2Ecom&urlhash=5
qRF&_t=tracking_anet> http://mywebsite.com");
set obj.http.Location = req.http.X-REDIRURL;
set obj.status = 301;
unset req.http.X-REDIRURL;
return(deliver);
}

But this does not redirect the user to the website, instead it delivers the
page.
Can anyone tell what I am missing?



Thanks

Puneet

_______________________________________________
varnish-misc mailing list
<mailto:varnish-misc [at] varnish-cache> varnish-misc [at] varnish-cache
<https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc>
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc


travis.crowder at spechal

Jul 27, 2013, 9:15 PM

Post #9 of 13 (133 views)
Permalink
Re: Stop users accessing website via IP address [In reply to]

I guess I am confused as to why you need the rewrite.

sub vcl_recv {
if(req.http.Host ~ "8.8.8.8") { error 750; }
}

sub vcl_error {
if(obj.status == 750) {
set obj.http.Location = "http://google.com/login";
set obj.status = 302;
return (deliver);
}
}

On Jul 27, 2013, at 10:03 PM, Travis Crowder <travis.crowder [at] spechal> wrote:

> 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.
>
> Can you elaborate on what you're trying set this header's value to?
>
> -Travis Crowder
>
>
> On Jul 27, 2013, at 9:38 PM, Puneet <puneet.arora [at] insticator> wrote:
>
>> HI Travis,
>>
>> Thanks for the reply.
>> I think that should work.
>>
>> Just one question.
>> In sub vcl_error() should I also change the
>>
>> set req.http.X-REDIRURL = regsub(req.url,"https?://[^/$]+", "http://mywebsite.com");
>> TO : à
>> set req.http.X-REDIRURL = regsub(req.http.host,"https?://[^/$]+", "http://mywebsite.com");
>> ?
>>
>> Because when replace req.url with req.http.host, It again stops working.
>> And If I don’t do it, the bowser gives an error “Too many redirects”
>>
>> Thanks
>> Puneet
>>
>> From: Travis Crowder [mailto:travis.crowder [at] spechal]
>> Sent: Saturday, July 27, 2013 7:53 PM
>> To: Puneet
>> Cc: varnish-misc [at] varnish-cache
>> Subject: Re: Stop users accessing website via IP address
>>
>> Check against req.http.Host
>>
>> In vcl_recv:
>>
>> if(req.http.Host ~ "8.8.8.8") {
>> error 750;
>> }
>>
>> -Travis Crowder
>>
>> On Jul 27, 2013, at 3:48 PM, Puneet <puneet.arora [at] insticator> wrote:
>>
>>
>> Hi all,
>>
>> I want to stop the users accessing my website via IP address.
>> I am using varnish as cache.
>> I have the following code in place but it is not working.
>>
>> In vcl_recv() {
>> if(req.url ~ "XX.XX.XXX.XXX") {
>> error 750 "Moved Permanently";
>> } }
>>
>> And in vcl_error()
>> sub vcl_error {
>> if (obj.status == 750) {
>> set req.http.X-REDIRURL = regsub(req.url,"https?://[^/$]+", "http://mywebsite.com");
>> set obj.http.Location = req.http.X-REDIRURL;
>> set obj.status = 301;
>> unset req.http.X-REDIRURL;
>> return(deliver);
>> }
>>
>> But this does not redirect the user to the website, instead it delivers the page.
>> Can anyone tell what I am missing?
>>
>> Thanks
>> Puneet
>> _______________________________________________
>> varnish-misc mailing list
>> varnish-misc [at] varnish-cache
>> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
>
> _______________________________________________
> varnish-misc mailing list
> varnish-misc [at] varnish-cache
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc


pprocacci at datapipe

Jul 27, 2013, 10:57 PM

Post #10 of 13 (133 views)
Permalink
Re: Stop users accessing website via IP address [In reply to]

> I guess I am confused as to why you need the rewrite.
>
> sub vcl_recv {
> if(req.http.Host ~ "8.8.8.8") { error 750; }
> }

Not to step on any toes.....

The above can have unwanted side effects. And not konwing
exactly how Puneet's machine is setup one should make it
explicit that the above will match a lot more then you
possibly intend.

8.8.8.8[0-9]

This being just an example. The first octet having the same
natural problem though that's less likely to happen.
You can fix the above problem be either anchor'ing your
match or using the appropriate operator '=='.

~Paul

________________________________

This message may contain confidential or privileged information. If you are not the intended recipient, please advise us immediately and delete this message. See http://www.datapipe.com/legal/email_disclaimer/ for further information on confidentiality and the risks of non-secure electronic communication. If you cannot access these links, please notify us by reply message and we will send the contents to you.

_______________________________________________
varnish-misc mailing list
varnish-misc [at] varnish-cache
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc


phk at phk

Jul 28, 2013, 12:12 AM

Post #11 of 13 (134 views)
Permalink
Re: Stop users accessing website via IP address [In reply to]

In message <000f01ce8b0a$a872c230$f9584690$@insticator.com>, Puneet writes:

>I want to stop the users accessing my website via IP address.
>I am using varnish as cache.
>I have the following code in place but it is not working.
>
>In vcl_recv() {
> if(req.url ~ "XX.XX.XXX.XXX") {

You should check the req.http.host header, that's where you will
find the IP# or hostname the user used.


--
Poul-Henning Kamp | UNIX since Zilog Zeus 3.20
phk [at] FreeBSD | TCP/IP since RFC 956
FreeBSD committer | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.

_______________________________________________
varnish-misc mailing list
varnish-misc [at] varnish-cache
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc


puneet.arora at insticator

Jul 28, 2013, 7:20 AM

Post #12 of 13 (126 views)
Permalink
RE: Stop users accessing website via IP address [In reply to]

Hi All,

Apologies for all this confusion and chaos.

I just don't want my website to be accessible by using the IP address on
which the website is hosted. Even if the Users use the IP address, I want
them to be redirected to my website.

It is the same way as www.facebook .com is hosted at "173.252.110.27".
When a user types "173.252.110.27" in the URL he is redirected to
"www.facebook.com"

I want to have the same functionality for mywebsite also.

To have this functionality I was trying Varnish to redirect the Users to
www.mywebsite.com .

Thanks
Puneet

-----Original Message-----
From: Poul-Henning Kamp [mailto:phk [at] phk]
Sent: Sunday, July 28, 2013 3:12 AM
To: Puneet
Cc: varnish-misc [at] varnish-cache
Subject: Re: Stop users accessing website via IP address

In message <000f01ce8b0a$a872c230$f9584690$@insticator.com>, Puneet writes:

>I want to stop the users accessing my website via IP address.
>I am using varnish as cache.
>I have the following code in place but it is not working.
>
>In vcl_recv() {
> if(req.url ~ "XX.XX.XXX.XXX") {

You should check the req.http.host header, that's where you will find the
IP# or hostname the user used.


--
Poul-Henning Kamp | UNIX since Zilog Zeus 3.20
phk [at] FreeBSD | TCP/IP since RFC 956
FreeBSD committer | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.


_______________________________________________
varnish-misc mailing list
varnish-misc [at] varnish-cache
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc


puneet.arora at insticator

Jul 28, 2013, 9:58 AM

Post #13 of 13 (118 views)
Permalink
RE: Stop users accessing website via IP address [In reply to]

Hi All,

Thanks for all the time.
I am able to get that working.
I was just missing :
set obj.http.Location = "http://mywebsite.com"+req.url;

Thanks
Puneet


-----Original Message-----
From: Puneet [mailto:puneet.arora [at] insticator]
Sent: Sunday, July 28, 2013 10:21 AM
To: 'Poul-Henning Kamp'; 'Travis Crowder'; 'Paul A. Procacci'
Cc: varnish-misc [at] varnish-cache
Subject: RE: Stop users accessing website via IP address

Hi All,

Apologies for all this confusion and chaos.

I just don't want my website to be accessible by using the IP address on
which the website is hosted. Even if the Users use the IP address, I want
them to be redirected to my website.

It is the same way as www.facebook .com is hosted at "173.252.110.27".
When a user types "173.252.110.27" in the URL he is redirected to
"www.facebook.com"

I want to have the same functionality for mywebsite also.

To have this functionality I was trying Varnish to redirect the Users to
www.mywebsite.com .

Thanks
Puneet

-----Original Message-----
From: Poul-Henning Kamp [mailto:phk [at] phk]
Sent: Sunday, July 28, 2013 3:12 AM
To: Puneet
Cc: varnish-misc [at] varnish-cache
Subject: Re: Stop users accessing website via IP address

In message <000f01ce8b0a$a872c230$f9584690$@insticator.com>, Puneet writes:

>I want to stop the users accessing my website via IP address.
>I am using varnish as cache.
>I have the following code in place but it is not working.
>
>In vcl_recv() {
> if(req.url ~ "XX.XX.XXX.XXX") {

You should check the req.http.host header, that's where you will find the
IP# or hostname the user used.


--
Poul-Henning Kamp | UNIX since Zilog Zeus 3.20
phk [at] FreeBSD | TCP/IP since RFC 956
FreeBSD committer | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.



_______________________________________________
varnish-misc mailing list
varnish-misc [at] varnish-cache
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc

Varnish misc RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.