apachefastcgi

How to set a fastcgi handler for a given file extension with mod_proxy_fcgi


I have a perl fastcgi script that listens on port 2022 of localhost that I want to use as handler for any file with the extension 'stml'. What has proved to be trivial on every other webserver is apparently impossible on the over-engineered garbage that is apache2. Based on what little documentation there is on the apache site my understanding is that this would work

<FilesMatch \.stml$>
SetHandler fcgi://127.0.0.1:2022/
</FilesMatch>

And I just get this

Error: 404
proxy:fcgi://127.0.0.1:2022//path/to/my/file/index.stml not found 

Have also tried SetHandler fcgi://127.0.0.1:2022 which just downloads an unhandled file with a random name like DgwDSlK.stml.


Solution

  • The call was coming from inside the house! That 404 was being printed by my fastcgi script in response to apache's truly brain dead (and obviously undocumented) decision to set $ENV{'SCRIPT_FILENAME'} to 'proxy:fcgi://127.0.0.1:2022/path/to/my/file/index.stml'. To make your fastcgi scripts portable between apache and non-broken web servers do something like $ENV{'SCRIPT_FILENAME'} =~ s/.*2022//; before opening it.