Apache Server configuration support - File access question

This is Interesting: Free IT Magazines  
Home > Archive > Apache Server configuration support > April 2007 > File access question





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author File access question
MaGazynieR

2007-04-27, 7:19 am

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
patpro ~ Patrick Proniewski

2007-04-27, 7:19 am

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/mo...tml#indexignore>


patpro

--
http://www.patpro.net/
Davide Bianchi

2007-04-27, 7:19 am

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

Davide

--
Windows NT: Only 16 megs needed to play Minesweeper!
MaGazynieR

2007-04-27, 7:19 am

Davide Bianchi pisze:
> On 2007-04-27, MaGazynieR <news@magazynier.dot.net> wrote:
>
> 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
MaGazynieR

2007-04-27, 7:19 am

patpro ~ Patrick Proniewski pisze:
> You might want to look at the IndexIgnore directive:
>
> <http://httpd.apache.org/docs/1.3/mo...tml#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
patpro ~ Patrick Proniewski

2007-04-27, 7:19 am

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

> patpro ~ Patrick Proniewski pisze:
> 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/
MaGazynieR

2007-04-27, 7:19 am

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
shimmyshack

2007-04-28, 1:19 pm

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


Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com