You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by rf <ru...@yahoo.com> on 2003/02/21 07:25:50 UTC

[users@httpd] Dispatching a resource ONLY with a check

I want to write a cgi based program that checks a url
like http://server.com/un/x90324 for a right
suffix(x90324) and then give out a resource,
particularly an tar.gz file. The constraints are:
1. This tar.gz file should not be directly accessible
for download.
2. The CGI program should not output this tar.gz
itself, rather forward it so that apache serves it
directly. Basically, the cgi program should act like a
filter.


If Apache's SetInputFilter is right here, can somebody
give me an example how to use it. Google is not giving
me examples for using it.

Thanks
rf

__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/

---------------------------------------------------------------------
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] Dispatching a resource ONLY with a check

Posted by Garth Winter Webb <ga...@perijove.com>.
Use mod_rewrite with a RewriteMap directive:

    RewriteLock /path/to/lock/file
    RewriteMap translate prg:/path/to/script.pl
    RewriteRule ^/un/(.*) ${translate:$1} [P]

The rewrite rule takes everything after '/un/' and passes it as a key to
the mapping function in '/path/to/script.pl'.  You have this script
decrypt the key into a real path name (or deny a key if its bogus) and
then returns a URL to some internal host which is served ala mod_proxy
via the P flag.  The URL remains unchanged, its processed by a script,
and then apache (albeit a different apache) serves it.

If you could use a DBM file if you just had a simple key to path
translation, and then you could lose the RewriteLock directive (only
needed for prg RewriteMaps).

    RewriteMap translate dbm:/path/to/dbmfile.db
    RewriteRule ^/un/(.*) ${translate:$1} [P]

Checkout:

    http://httpd.apache.org/docs/mod/mod_rewrite.html#RewriteMap

I don't know anything about SetInputFilter, so I can't help you there.

Garth

On Thu, 2003-02-20 at 22:25, rf wrote:
> I want to write a cgi based program that checks a url
> like http://server.com/un/x90324 for a right
> suffix(x90324) and then give out a resource,
> particularly an tar.gz file. The constraints are:
> 1. This tar.gz file should not be directly accessible
> for download.
> 2. The CGI program should not output this tar.gz
> itself, rather forward it so that apache serves it
> directly. Basically, the cgi program should act like a
> filter.
> 
> 
> If Apache's SetInputFilter is right here, can somebody
> give me an example how to use it. Google is not giving
> me examples for using it.
> 
> Thanks
> rf
> 
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Tax Center - forms, calculators, tips, more
> http://taxes.yahoo.com/
> 
> ---------------------------------------------------------------------
> 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
-- 
Garth Winter Webb <ga...@perijove.com>

---------------------------------------------------------------------
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