[prev in list] [next in list] [prev in thread] [next in thread]
List: apache-modperl
Subject: Re: Configuring mod-Perl to handle only some file types
From: "Ekki Plicht (DF4OR)" <ekki () plicht ! de>
Date: 2012-08-08 19:48:57
Message-ID: CAMmwEgPA+ntBv+ENwQo2-2WMG79ROrAsjppVeTB2n7fbRYKQWw () mail ! gmail ! com
[Download RAW message or body]
On Wed, Aug 8, 2012 at 9:30 PM, <jniederberger@comcast.net> wrote:
> Thank you – both Kevin and Ekki
>
> For my purposes I think Ekki's idea sounds more like it could work.
>
> Ekki – would you know how to phrase that match in the negative?
> In other words, write a regex to match .jpeg, .doc, ....etc. etc.
> and if those matches FAIL - then use perl handler?
>
Joe,
I don't think that that approach will work in the long term. What if
someone wants to serve a file *.xyz in the future? You would have to
adjust that regex. And again, and again...
I think it would be much easier to set up <DirectoryMatch 'regex'> and
<FilesMatch 'regex'> sections for what you want to serve by your
handler(s), and let Apache handle _all_ other files/dirs.
Filter on what is the smaller set - and I think that's your dirs and .html
files. All other files not mentioned in those <*Match ...> sections are
automatically handled by Apache. Further - a regex matching all those files
you don't want to handle yourself would be rather lengthy and unwieldy.
Take a look at Apaches fine documentation, look for <DirectoryMatch ...>
and <FilesMatch ...> directives.
http://httpd.apache.org/docs/2.2/mod/core.html#directorymatch
http://httpd.apache.org/docs/2.2/mod/core.html#filesmatch
For example, a <FilesMatch ...> for . htm or .html Files would look like
(untested):
PerlRequire /var/www/mysite/cgi-bin/my_modperl_module.pm
<FilesMatch "\.html?$">
SetHandler perl-script
PerlResponseHandler my_modperl_module # which contains a sub
handler {...};
</FilesMatch>
Cheers,
Ekki
>
>
>
>
> *From:* Ekki Plicht (DF4OR) <ekki@plicht.de>
> *Sent:* Wednesday, August 08, 2012 2:23 PM
> *To:* mod_perl list <modperl@perl.apache.org>
> *Subject:* Re: Configuring mod-Perl to handle only some file types
>
>
>
> On Wed, Aug 8, 2012 at 8:13 PM, <jniederberger@comcast.net> wrote:
>
>> Hello,
>>
>> I have a mod_perl program that is written to handle URL's that
>> name either a directory or *.html type files. All other types
>> I want Apache to just do its regular thing (e.g., serve image
>> type files, or .doc, .pdf, .js, .css, etc.)
>> What's a good way to configure that? So for an entire website directory,
>> and all its substructure, my perl handler gets only directories
>> or *.html files, and apache handles everything else without
>> involing my perl handler.
>>
>>
>>
> I just used a <FilesMatch> section in httpd.conf. Like so:
> <FilesMatch "\.(tx|html\...)$">
> SetHandler perl-script
> PerlResponseHandler TxShow
> </FilesMatch>
>
> This match expression filters out any files that either end in .html.?? or
> .tx.??, the two ?? being language extensions used for auto negotiation.
>
> You can build nearly any kind of Regex there to filter out what you want
> handled by your mod_perl script and what should be handled by Apache
> directly.
>
> Cheers,
> Ekki
>
>
>
[Attachment #3 (text/html)]
<br><br><div class="gmail_quote">On Wed, Aug 8, 2012 at 9:30 PM, <span \
dir="ltr"><<a href="mailto:jniederberger@comcast.net" \
target="_blank">jniederberger@comcast.net</a>></span> wrote:<br><blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex">
<div dir="ltr">
<div dir="ltr">
<div style="font-size:12pt;font-family:'Calibri'">
<div>Thank you – both Kevin and Ekki </div>
<div> </div>
<div>For my purposes I think Ekki's idea sounds more like it could work.</div>
<div><br>Ekki – would you know how to phrase that match in the negative?</div>
<div>In other words, write a regex to match .jpeg, .doc, ....etc. etc.</div>
<div>and if those matches FAIL - then use perl handler?</div>
<div></div></div></div></div></blockquote><div><br>Joe,<br>I don't think that \
that approach will work in the long term. What if someone wants to serve a file *.xyz \
in the future? You would have to adjust that regex. And again, and again...<br> \
<br>I think it would be much easier to set up <DirectoryMatch 'regex'> \
and <FilesMatch 'regex'> sections for what you want to serve by your \
handler(s), and let Apache handle _all_ other files/dirs.<br> <br>Filter on what is \
the smaller set - and I think that's your dirs and .html files. All other files \
not mentioned in those <*Match ...> sections are automatically handled by \
Apache. Further - a regex matching all those files you don't want to handle \
yourself would be rather lengthy and unwieldy.<br> <br>Take a look at Apaches fine \
documentation, look for <DirectoryMatch ...> and <FilesMatch ...> \
directives.<br><a href="http://httpd.apache.org/docs/2.2/mod/core.html#directorymatch">http://httpd.apache.org/docs/2.2/mod/core.html#directorymatch</a><br>
<a href="http://httpd.apache.org/docs/2.2/mod/core.html#filesmatch">http://httpd.apache.org/docs/2.2/mod/core.html#filesmatch</a><br><br>For \
example, a <FilesMatch ...> for . htm or .html Files would look like \
(untested):<br> <br> PerlRequire /var/www/mysite/cgi-bin/<a \
href="http://my_modperl_module.pm">my_modperl_module.pm</a><br> <br> \
<FilesMatch "\.html?$"><br> SetHandler perl-script<br> \
PerlResponseHandler my_modperl_module # which contains a sub handler {...};<br> \
</FilesMatch><br><br>Cheers,<br>Ekki <br><br><br> </div><blockquote \
class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid \
rgb(204,204,204);padding-left:1ex"> <div dir="ltr"><div dir="ltr"><div \
style="font-size:12pt;font-family:'Calibri'"><div> </div><br><div> </div> \
<div style="font-size:small;font-style:normal;text-decoration:none;font-family:'Calibri';display:inline;font-weight:normal">
<div style="FONT:10pt tahoma">
<div> </div>
<div style="BACKGROUND:#f5f5f5">
<div><b>From:</b> <a title="ekki@plicht.de" href="mailto:ekki@plicht.de" \
target="_blank">Ekki Plicht (DF4OR)</a> </div> <div><b>Sent:</b> Wednesday, August \
08, 2012 2:23 PM</div> <div><b>To:</b> <a title="modperl@perl.apache.org" \
href="mailto:modperl@perl.apache.org" target="_blank">mod_perl list</a> </div> \
<div><b>Subject:</b> Re: Configuring mod-Perl to handle only some file \
types</div></div></div> <div> </div></div>
<div style="font-size:small;font-style:normal;text-decoration:none;font-family:'Calibri';display:inline;font-weight:normal"><br><br>
<div class="gmail_quote">On Wed, Aug 8, 2012 at 8:13 PM, <span dir="ltr"><<a \
href="mailto:jniederberger@comcast.net" \
target="_blank">jniederberger@comcast.net</a>></span> wrote:<br> <blockquote \
style="BORDER-LEFT:#ccc 1px solid;MARGIN:0px 0px 0px 0.8ex;PADDING-LEFT:1ex" \
class="gmail_quote">Hello,<br><br>I have a mod_perl program that is written to \
handle URL's that<br>name either a directory or *.html type files. All other \
types<br>I want Apache to just do its regular thing (e.g., serve image<br>type \
files, or .doc, .pdf, .js, .css, etc.) <br>What's a good way to configure that? \
So for an entire website directory, and all its substructure, my perl handler gets \
only directories<br>or *.html files, and apache handles everything else \
without<br>involing my perl handler.<br><br><br></blockquote></div><br>I just used a \
<FilesMatch> section in httpd.conf. Like so:<br>
<FilesMatch
"\.(tx|html\...)$"><br>
SetHandler
perl-script<br>
PerlResponseHandler TxShow<br>
</FilesMatch><br><br>This match expression filters out any files that
either end in .html.?? or .tx.??, the two ?? being language extensions used for
auto negotiation.<br><br>You can build nearly any kind of Regex there to filter
out what you want handled by your mod_perl script and what should be handled by
Apache
directly.<br><br>Cheers,<br>Ekki<br><br><br></div></div></div></div>
</blockquote></div><br>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic