I have an unusual requirement for a poject im working on.
What I need to do is somehow make it so that an ip address is able to
hit a
folder but anyone not on that address will get a 404 or 403 message.
Im not much of a perl programmer however what i need it to do is this
$ip = $r->remote_addr ;
$request = “/htdocs/111222333444-123456789/blah/”; # this would be the
$r->uri i think
$ip =~ s/.//g;
$request =~ //htdocs/([0-9]+)-([0-9]+)/blah//; # matches the
111222333444 and 123456789 in the request
if ($ip == $1){
print “allow”; # allow it to open the file/folder
} else {
print “404”; # send a 404 or 403 message to the client
}
I hope this example sort of shows what I need to happen, however I have
no
idea how to use the perl-embed module to make it work.
Kingsley F.
Technical Leader Content Services / Content Management Group
=============================================
Internode Systems Pty Ltd
PO Box 284, Rundle Mall 5000
Level 3, 132 Grenfell Street, Adelaide 5000
Phone: +61 8 8228 2978
Fax: +61 8 8235 6978
Web: http://www.internode.on.net
http://games.internode.on.net
On Wed, Oct 31, 2007 at 01:04:52AM +1030, Kingsley F. wrote:
$ip =~ s/.//g;
idea how to use the perl-embed module to make it work.
The usual way is veriable handler:
http {
perl_set $forbidden forbidden::handler;
server {
location / {
if ($forbidden) {
return 403;
}
root ...
...
}
forbidden.pm:
package forbidden;
use nginx;
sub handler {
my $ip = r->remote_addr;
my $uri = r->uri;
…
if ($ip == $1) {
return “1”;
}
return “”;
}
I can make sense of that,
awesome thanks for the help, I never stop being impressed with nginx.
It is currently doing 75MB/s on one of my boxes atm
Kingsley
----- Original Message -----
From: “Igor S.” [email protected]
To: [email protected]
Sent: Wednesday, October 31, 2007 3:37 AM
Subject: Re: Unusual requirement using perl?
Bytes
----- Original Message -----
From: “Igor S.” [email protected]
To: [email protected]
Sent: Wednesday, October 31, 2007 6:05 PM
Subject: Re: Unusual requirement using perl?
On Wed, Oct 31, 2007 at 06:15:27PM +1030, Kingsley F. wrote:
Bytes
It’s good. What OS and network card ?
On Wed, Oct 31, 2007 at 03:48:05AM +1030, Kingsley F. wrote:
It is currently doing 75MB/s on one of my boxes atm
Mbyte/s or Mbits/s ?
sun v20z and apple xserv, gentoo Linux , 2 broadcom tg3 cards bonded,
the
fastest I have seen it is 115MB/s (Bytes again)
im running 6 children, perl and flv modules, it runs very smoothly and
servers out a peak of about 3000 connections.
the website is here http://games.internode.on.net/ and nginx is used on
the
file web server and file mirrors.
Kingsley
----- Original Message -----
From: “Igor S.” [email protected]
To: [email protected]
Sent: Wednesday, October 31, 2007 6:29 PM
Subject: Re: Unusual requirement using perl?