File access question

This is a discussion on File access question within the Apache Web Server forums, part of the Web Server and Related Forums category; Hi all I want to display only selected files (for example with mask 'my_file') by Options +Indexes In folder are ...


Go Back   Usenet Forums > Web Server and Related Forums > Apache Web Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-27-2007
MaGazynieR
 
Posts: n/a
Default File access question

Hi all
I want to display only selected files (for example with mask 'my_file')
by Options +Indexes
In folder are different files.
I tried use scenario in conf file:

Alias /a d:/test
<Directory d:/test>
IndexOptions FancyIndexing HTMLTable VersionSort
SuppressColumnSorting SuppressLastModified SuppressDescription IgnoreClient
Options +Indexes
Order deny,allow
Deny from all
</Directory>
<Files ~ ".my_file.">
Order deny,allow
Allow from all
</Files>
But isn't work.

How I should configure Apache ?

Regards
--
MaGazynieR at magazynier.net
  #2 (permalink)  
Old 04-27-2007
patpro ~ Patrick Proniewski
 
Posts: n/a
Default Re: File access question

In article <f0se0r$j60$1@atlantis.news.tpi.pl>,
MaGazynieR <news@magazynier.dot.net> wrote:

> Hi all
> I want to display only selected files (for example with mask 'my_file')
> by Options +Indexes
> In folder are different files.
> I tried use scenario in conf file:
>
> Alias /a d:/test
> <Directory d:/test>
> IndexOptions FancyIndexing HTMLTable VersionSort
> SuppressColumnSorting SuppressLastModified SuppressDescription IgnoreClient
> Options +Indexes
> Order deny,allow
> Deny from all
> </Directory>
> <Files ~ ".my_file.">
> Order deny,allow
> Allow from all
> </Files>
> But isn't work.
>
> How I should configure Apache ?


You might want to look at the IndexIgnore directive:

<http://httpd.apache.org/docs/1.3/mod/mod_autoindex.html#indexignore>


patpro

--
http://www.patpro.net/
  #3 (permalink)  
Old 04-27-2007
MaGazynieR
 
Posts: n/a
Default Re: File access question

Davide Bianchi pisze:
> On 2007-04-27, MaGazynieR <news@magazynier.dot.net> wrote:
>> <Files ~ ".my_file.">

>
> Your file ain't called ".my_file." (note: there are dots)
> try with
>
> "^my_file"
>
> instead

Hi
Thank's for answer.

Result:
"Forbidden
You don't have permission to access /a/ on this server.
Apache/2.2.3 (Win32) PHP/5.2.0 Server at localhost Port 8080"

Maybe it's not clear what I want. Maybe I going wrong way.
I want display only one file type (named 'my_file') through many folders
by mod_autoindex. Rest files should be hidden and not accessible.

Regards
--
MaGazynieR
  #4 (permalink)  
Old 04-27-2007
MaGazynieR
 
Posts: n/a
Default Re: File access question

patpro ~ Patrick Proniewski pisze:
> You might want to look at the IndexIgnore directive:
>
> <http://httpd.apache.org/docs/1.3/mod/mod_autoindex.html#indexignore>

Hi
I tried. It's not what I want because it hide files direct, without
negation (there should be all except 'my_file' what is imposible IMHO
with this directive).

--
MaGazynieR
  #5 (permalink)  
Old 04-27-2007
patpro ~ Patrick Proniewski
 
Posts: n/a
Default Re: File access question

In article <f0sg0l$rab$1@nemesis.news.tpi.pl>,
MaGazynieR <news@magazynier.dot.net> wrote:

> patpro ~ Patrick Proniewski pisze:
> > You might want to look at the IndexIgnore directive:
> >
> > <http://httpd.apache.org/docs/1.3/mod/mod_autoindex.html#indexignore>

> Hi
> I tried. It's not what I want because it hide files direct, without
> negation (there should be all except 'my_file' what is imposible IMHO
> with this directive).


you're right, unfortunately, I see no way to achieve your goal with
only Apache directives.
I know Apache 2.2 will not list files that are denied by configuration
(I don't know about 1.3 or 2.0), and may be a FilesMatch directive would
help you. But I just can't make things work with a "negative" regex.

patpro

--
http://www.patpro.net/
  #6 (permalink)  
Old 04-27-2007
MaGazynieR
 
Posts: n/a
Default Re: File access question

patpro ~ Patrick Proniewski pisze:
> you're right, unfortunately, I see no way to achieve your goal with
> only Apache directives.
> I know Apache 2.2 will not list files that are denied by configuration
> (I don't know about 1.3 or 2.0), and may be a FilesMatch directive would
> help you. But I just can't make things work with a "negative" regex.

Uff. I come to this same conclusion but I'm not Apache professional.
Thanks
--
MaGazynieR
  #7 (permalink)  
Old 04-28-2007
shimmyshack
 
Posts: n/a
Default Re: File access question

On Apr 27, 11:34 am, MaGazynieR <n...@magazynier.dot.net> wrote:
> patpro ~ Patrick Proniewski pisze:> you're right, unfortunately, I see no way to achieve your goal with
> > only Apache directives.
> > I know Apache 2.2 will not list files that are denied by configuration
> > (I don't know about 1.3 or 2.0), and may be a FilesMatch directive would
> > help you. But I just can't make things work with a "negative" regex.

>
> Uff. I come to this same conclusion but I'm not Apache professional.
> Thanks
> --
> MaGazynieR


what a good question!, on latest apache/xp pro sp2, trial and error
shows it's possible.
the key is not denying the filetypes that apache uses in the
DirectoryIndex
for that directory, on my system, the default index files are
index.htm
index.html
index.shtml
index.php
index.pl
index.cgi
which can be covered by the following reg exp
<FilesMatch "(s?html?|php|cgi|pl)$">

So the trick is to ban all the files that could be indexed, I do this
below by using a "file extension appraoch" which wont catch files
which do not have file extensions. the reg exp used is
<FilesMatch "\.[A-Za-z0-9]{1,4}$">
which I know is not going to be generic enough to catch everything.
The one unsolved part of this is that if you use
<FilesMatch ".*">
to deny the files, then the directory listing is completely denied.
Perhaps someone can help there.

So say the mask I want is to allow only files ending in .exe (adjust
your mask accordingly)
(if you copy and paste watch out for broken lines)

<Directory "path/to/folder">
Options Indexes MultiViews FollowSymLinks
IndexOptions +FancyIndexing -IconsAreLinks +FoldersFirst +NameWidth=*
+IgnoreCase +SuppressDescription +SuppressHTMLPreamble
AllowOverride None

#need this to override a previous global deny all directive
Order Deny,Allow
#now all files are allowed and will be indexed

#now deny certain filetypes, we could use a list
#<FilesMatch "(exe|iso|msi|chm|mp3|sql|zip|7z|xml|msg|pdf|jpe?g |png|
gif)$">
#but thats not generic enough, so we use
<FilesMatch "\.[A-Za-z0-9]{1,4}$">
Order Allow,Deny
</FilesMatch>

#next we override the ban list above, to re-allow the mask
#but we must add to this mask all the files that apache
#has in the DirectoryIndex directive, (see above)
<FilesMatch "(exe|s?html?|php|cgi|pl)$">
Order Deny,Allow
</FilesMatch>

#but this means that if we have files ending in
#.php .html .shtml etc... in the directory they
#will be listed too, so we counter this with a
#final IndexIgnore directive, which is in my
#case quite a long list of default index files,
IndexIgnore *.shtml *.htm *.html *.php *.cgi *.pl

#that's it, the only files which will now show
#are those ending in .exe, adjust your
#reg exp to suit

</Directory>


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 06:14 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0