PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Hébergement serveur > comp.info.servers.unix > Apache file download permissions
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.info.servers.unix Web servers for UNIX platforms.

Apache file download permissions

Réponse
 
LinkBack Outils de la discussion
Vieux 03/06/2008, 14h03   #1
Ivan Voras
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Apache file download permissions

Hi,

I'm sure this is a common problem but I can't find any off the shelf
solutions: there's a dynamic (PHP) web site and the requirement is that
visitors can download files, but the files have their permissions
regulated by the web application (i.e. certain users can download
certain files). The obvious solution is to download all files through
PHP (i.e. a PHP script checks permissions, reads file, writes it as its
output), but this has proven to be inefficient and we'd like to have
Apache directly handling the file download (using sendfile and other
optimizations it has).

Lighttpd has something like that:
http://trac.lighttpd.net/trac/wiki/D...BeforeDownload but
it's too rudimentary for our needs. At the very least we'd like
something that makes Apache check in a database and see if the client's
IP address is allowed to download the file requested (settable per
<Directory>), and the best solution would be to inspect the client's .

Any pointers on where to look?


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFIRTMFldnAQVacBcgRAur9AJ9ndfQlx3HGZdaA6y/2KMd27FMqsQCgo8Ug
gyHGEXcef9O1AS1FNoXzhpU=
=X6wi
-----END PGP SIGNATURE-----

  Réponse avec citation
Vieux 05/06/2008, 03h48   #2
C.
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Apache file download permissions

On Jun 3, 1:03pm, Ivan Voras <ivoras@__fer.hr__> wrote:
> Hi,
>
> I'm sure this is a common problem but I can't find any off the shelf
> solutions: there's a dynamic (PHP) web site and the requirement is that
> visitors can download files, but the files have their permissions
> regulated by the web application (i.e. certain users can download
> certain files). The obvious solution is to download all files through
> PHP (i.e. a PHP script checks permissions, reads file, writes it as its
> output), but this has proven to be inefficient and we'd like to have
> Apache directly handling the file download (using sendfile and other
> optimizations it has).
>
> Lighttpd has something like that:http://trac.lighttpd.net/trac/wiki/D...oreDownloadbut
> it's too rudimentary for our needs. At the very least we'd like
> something that makes Apache check in a database and see if the client's
> IP address is allowed to download the file requested (settable per
> <Directory>), and the best solution would be to inspect the client's .
>
> Any pointers on where to look?
>
> signature.asc
> 1KDownload


Why do you think streaming the file via PHP is significantly more
expensive? The short answer is that its not possible to what you ask
unless you reimplemented your own version of the Lighttpd module
(although I'm unclear how you would securely prevent leeching using
this). An interim solution might be to keep the docs out of the
webroot, then when a valid request arrives, parse it with PHP, copy
the file into the webrrot with a random name, and redict the browser
to it, then periodically, tidy up the random files. But I suspect
you'd get a lot of mileage out of optimizing the PHP code.

C.
  Réponse avec citation
Vieux 05/06/2008, 03h48   #3
C.
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Apache file download permissions

On Jun 3, 1:03pm, Ivan Voras <ivoras@__fer.hr__> wrote:
> Hi,
>
> I'm sure this is a common problem but I can't find any off the shelf
> solutions: there's a dynamic (PHP) web site and the requirement is that
> visitors can download files, but the files have their permissions
> regulated by the web application (i.e. certain users can download
> certain files). The obvious solution is to download all files through
> PHP (i.e. a PHP script checks permissions, reads file, writes it as its
> output), but this has proven to be inefficient and we'd like to have
> Apache directly handling the file download (using sendfile and other
> optimizations it has).
>
> Lighttpd has something like that:http://trac.lighttpd.net/trac/wiki/D...oreDownloadbut
> it's too rudimentary for our needs. At the very least we'd like
> something that makes Apache check in a database and see if the client's
> IP address is allowed to download the file requested (settable per
> <Directory>), and the best solution would be to inspect the client's .
>
> Any pointers on where to look?
>
> signature.asc
> 1KDownload


Why do you think streaming the file via PHP is significantly more
expensive? The short answer is that its not possible to what you ask
unless you reimplemented your own version of the Lighttpd module
(although I'm unclear how you would securely prevent leeching using
this). An interim solution might be to keep the docs out of the
webroot, then when a valid request arrives, parse it with PHP, copy
the file into the webrrot with a random name, and redict the browser
to it, then periodically, tidy up the random files. But I suspect
you'd get a lot of mileage out of optimizing the PHP code.

C.
  Réponse avec citation
Vieux 05/06/2008, 15h45   #4
Ivan Voras
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Apache file download permissions

C. wrote:
> On Jun 3, 1:03 pm, Ivan Voras <ivoras@__fer.hr__> wrote:
>> Hi,
>>
>> I'm sure this is a common problem but I can't find any off the shelf
>> solutions: there's a dynamic (PHP) web site and the requirement is that
>> visitors can download files, but the files have their permissions
>> regulated by the web application (i.e. certain users can download
>> certain files). The obvious solution is to download all files through
>> PHP (i.e. a PHP script checks permissions, reads file, writes it as its
>> output), but this has proven to be inefficient and we'd like to have
>> Apache directly handling the file download (using sendfile and other
>> optimizations it has).
>>
>> Lighttpd has something like that:http://trac.lighttpd.net/trac/wiki/D...oreDownloadbut
>> it's too rudimentary for our needs. At the very least we'd like
>> something that makes Apache check in a database and see if the client's
>> IP address is allowed to download the file requested (settable per
>> <Directory>), and the best solution would be to inspect the client's .
>>
>> Any pointers on where to look?


>
> Why do you think streaming the file via PHP is significantly more
> expensive? The short answer is that its not possible to what you ask
> unless you reimplemented your own version of the Lighttpd module
> (although I'm unclear how you would securely prevent leeching using
> this). An interim solution might be to keep the docs out of the
> webroot, then when a valid request arrives, parse it with PHP, copy
> the file into the webrrot with a random name, and redict the browser
> to it, then periodically, tidy up the random files. But I suspect
> you'd get a lot of mileage out of optimizing the PHP code.


It is not expensive in terms of CPU time, but it is expensive in terms
of PHP interpreters loaded in memory at any one time (we're using
FastCGI). Downloads are somewhat less important to us than "regular" web
page renderings and allocating a full PHP process (each of which is > 25
MB RES size in memory +other resources like open file descriptors etc)
soon ties up resources that could be assigned to generating web pages.

What I think I'd need is a apache module for authorization that either
allows me to script something to my liking (mod_perl?) or something that
has a simple by-IP check.


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFIR+3nldnAQVacBcgRAvgTAJwIjm4YiLOrEZtYSsdH3z Bn6vAVaACdGrcz
WG5fj8igyv2Mw9MurBbmUt8=
=DraL
-----END PGP SIGNATURE-----

  Réponse avec citation
Vieux 05/06/2008, 15h45   #5
Ivan Voras
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Apache file download permissions

C. wrote:
> On Jun 3, 1:03 pm, Ivan Voras <ivoras@__fer.hr__> wrote:
>> Hi,
>>
>> I'm sure this is a common problem but I can't find any off the shelf
>> solutions: there's a dynamic (PHP) web site and the requirement is that
>> visitors can download files, but the files have their permissions
>> regulated by the web application (i.e. certain users can download
>> certain files). The obvious solution is to download all files through
>> PHP (i.e. a PHP script checks permissions, reads file, writes it as its
>> output), but this has proven to be inefficient and we'd like to have
>> Apache directly handling the file download (using sendfile and other
>> optimizations it has).
>>
>> Lighttpd has something like that:http://trac.lighttpd.net/trac/wiki/D...oreDownloadbut
>> it's too rudimentary for our needs. At the very least we'd like
>> something that makes Apache check in a database and see if the client's
>> IP address is allowed to download the file requested (settable per
>> <Directory>), and the best solution would be to inspect the client's .
>>
>> Any pointers on where to look?


>
> Why do you think streaming the file via PHP is significantly more
> expensive? The short answer is that its not possible to what you ask
> unless you reimplemented your own version of the Lighttpd module
> (although I'm unclear how you would securely prevent leeching using
> this). An interim solution might be to keep the docs out of the
> webroot, then when a valid request arrives, parse it with PHP, copy
> the file into the webrrot with a random name, and redict the browser
> to it, then periodically, tidy up the random files. But I suspect
> you'd get a lot of mileage out of optimizing the PHP code.


It is not expensive in terms of CPU time, but it is expensive in terms
of PHP interpreters loaded in memory at any one time (we're using
FastCGI). Downloads are somewhat less important to us than "regular" web
page renderings and allocating a full PHP process (each of which is > 25
MB RES size in memory +other resources like open file descriptors etc)
soon ties up resources that could be assigned to generating web pages.

What I think I'd need is a apache module for authorization that either
allows me to script something to my liking (mod_perl?) or something that
has a simple by-IP check.


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFIR+3nldnAQVacBcgRAvgTAJwIjm4YiLOrEZtYSsdH3z Bn6vAVaACdGrcz
WG5fj8igyv2Mw9MurBbmUt8=
=DraL
-----END PGP SIGNATURE-----

  Réponse avec citation
Vieux 05/06/2008, 16h55   #6
Nick Kew
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Apache file download permissions

On Tue, 03 Jun 2008 14:03:17 +0200
Ivan Voras <ivoras@__fer.hr__> wrote:

> Lighttpd has something like that:
> http://trac.lighttpd.net/trac/wiki/D...BeforeDownload but
> it's too rudimentary for our needs. At the very least we'd like
> something that makes Apache check in a database and see if the
> client's IP address is allowed to download the file requested
> (settable per <Directory>), and the best solution would be to inspect
> the client's .


Apache's mod_rewrite will do that for you. You can use the "RewriteMap"
directive to make it look in a database.

--
Nick Kew

Application Development with Apache - the Apache Modules Book
http://www.apachetutor.org/
  Réponse avec citation
Vieux 05/06/2008, 16h55   #7
Nick Kew
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Apache file download permissions

On Tue, 03 Jun 2008 14:03:17 +0200
Ivan Voras <ivoras@__fer.hr__> wrote:

> Lighttpd has something like that:
> http://trac.lighttpd.net/trac/wiki/D...BeforeDownload but
> it's too rudimentary for our needs. At the very least we'd like
> something that makes Apache check in a database and see if the
> client's IP address is allowed to download the file requested
> (settable per <Directory>), and the best solution would be to inspect
> the client's .


Apache's mod_rewrite will do that for you. You can use the "RewriteMap"
directive to make it look in a database.

--
Nick Kew

Application Development with Apache - the Apache Modules Book
http://www.apachetutor.org/
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 07h14.


Édité par : vBulletin® version 3.7.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,14989 seconds with 15 queries