You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by McDouglas <mc...@axelero.hu> on 2006/01/29 04:53:21 UTC

[users@httpd] access control based on time of day

Hi,

I have some trouble figuring out how to set up apache to allow remote users
to request pages only at a given time of day.

I've read the documentations of mod_access and mod_auth, but could not find
any information.

"Access can be granted or denied based on a wide variety of criteria, such
as the network address of the client, the TIME OF DAY, the phase of the
moon, or the browser which the visitor is using."
(http://httpd.apache.org/docs/1.3/howto/auth.html)

After reading this, I hoped it is possible to do. Any ideas?

Thanks.


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] access control based on time of day

Posted by Nick Kew <ni...@webthing.com>.
On Sunday 29 January 2006 03:53, McDouglas wrote:
> Hi,
>
> I have some trouble figuring out how to set up apache to allow remote users
> to request pages only at a given time of day.
>
> I've read the documentations of mod_access and mod_auth, but could not find
> any information.
>
> "Access can be granted or denied based on a wide variety of criteria, such
> as the network address of the client, the TIME OF DAY, the phase of the
> moon, or the browser which the visitor is using."
> (http://httpd.apache.org/docs/1.3/howto/auth.html)
>
> After reading this, I hoped it is possible to do. Any ideas?

It's possible.  You need a Require directive that'll look something like

Require time 09:00-17:00

But - you need a module to do it.  I wrote a module to permit access
according to day-of-the-week as a simple example for the modules book.
If you're happy hacking C, I'm happy to let you have that as a startingpoint.

-- 
Nick Kew

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] access control based on time of day

Posted by Joshua Slive <jo...@slive.ca>.
On 1/29/06, Nick Kew <ni...@webthing.com> wrote:
> On Sunday 29 January 2006 03:53, McDouglas wrote:
>
> > I've read the documentations of mod_access and mod_auth, but could not find
> > any information.
> >
> > "Access can be granted or denied based on a wide variety of criteria, such
> > as the network address of the client, the TIME OF DAY, the phase of the
> > moon, or the browser which the visitor is using."
> > (http://httpd.apache.org/docs/1.3/howto/auth.html)
> >
> > After reading this, I hoped it is possible to do. Any ideas?
>
> Come to think of it, you could presumably also work around it with
> mod_rewrite and a rewriterule that sends users to a "go away" page
> at forbidden times.  But that's going to be a bit of a nightmare if you
> want, for example, to permit *some* users access all the time.

In fact, there is a "Time-Dependent Rewriting" example in
http://httpd.apache.org/docs/2.2/misc/rewriteguide.html
and you can forbid access using the [F] flag to RewriteRule.

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] access control based on time of day

Posted by Nick Kew <ni...@webthing.com>.
On Sunday 29 January 2006 03:53, McDouglas wrote:

> I've read the documentations of mod_access and mod_auth, but could not find
> any information.
>
> "Access can be granted or denied based on a wide variety of criteria, such
> as the network address of the client, the TIME OF DAY, the phase of the
> moon, or the browser which the visitor is using."
> (http://httpd.apache.org/docs/1.3/howto/auth.html)
>
> After reading this, I hoped it is possible to do. Any ideas?

Come to think of it, you could presumably also work around it with
mod_rewrite and a rewriterule that sends users to a "go away" page
at forbidden times.  But that's going to be a bit of a nightmare if you
want, for example, to permit *some* users access all the time.

-- 
Nick Kew

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] access control based on time of day

Posted by Jean Bonnot <hb...@link2mail.net>.
McDouglas a écrit :

>Hi,
>
>I have some trouble figuring out how to set up apache to allow remote users
>to request pages only at a given time of day.
>
>I've read the documentations of mod_access and mod_auth, but could not find
>any information.
>
>"Access can be granted or denied based on a wide variety of criteria, such
>as the network address of the client, the TIME OF DAY, the phase of the
>moon, or the browser which the visitor is using."
>(http://httpd.apache.org/docs/1.3/howto/auth.html)
>
>After reading this, I hoped it is possible to do. Any ideas?
>  
>
with a little shell script it would be easy :

---------------------------------------------
#!/bin/sh

hour=`date +"%H"`

if [ $hour < 09 -a $hour > 18 ]; then
# this is not the good time
cat << __eof__
Location: /redirect/to/goaway/page.html

__eof__
# notice the empty line after the "location:" !!!
else
# This guy is in the good time-slice
cat /where-the-good-web-page-is/thepage.html
fi

#
# Don't use a "location:" to redirect the user to the good page !
#
-------------------------------------------------------




---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org