Item6087: TSA FastCgi crashes

pencil
Priority: Urgent
Current State: Closed
Released In: n/a
Target Release: n/a
Applies To: Extension
Component: FastCGIEngineContrib
Branches: master
Reported By: SvenDowideit
Waiting For:
Last Change By: GilmarSantosJr
I thought I'd try out fastcgi engie in a real world situation - DreamHost

which means you don't get to use Alias or any of the FastCgiServer directives in the htaccess file - you're supposed to just use a .fcgi ending, and it is supposed to work.

it falls flat with a 500 error, and there's not enough info in any logs I could find to fix or diagnose.

-- TWiki:Main/SvenDowideit - 21 Oct 2008

This one can be hard to solve cause I don't have a DreamHost account to test it on...

FastCGI engine in trunk still needs some updates, due to changes I made to trunk after the merge. But it was supposed at least to work for simple and common situations. Currently it really needs an Alias statement, mapping the bin url dir to foswiki.fcgi script, so the action becomes part of the PATH_INFO. I'll try to set up my apache as described at DreamHost documentation and test it.

Maybe, if mod_actions and mod_mime are available and enabled, something like this could work:
# .htaccess of foswiki bin directory
SetHandler foswiki-fastcgi
Action foswiki-fastcgi /foswiki/bin/foswiki.fcgi
<Files "foswiki.fcgi">
   SetHandler fastcgi-script
</Files>

-- TWiki:Main.GilmarSantosJr - 22 Oct 2008

I'll set you up an account on DH soon - but in my opinion, the fastcgi support needs to work for the dumbest setup too -

where all you get is
AddHandler fastcgi-script .fcgi
Options +FollowSymLinks +ExecCGI

the lack of logging bothers me quite a bit thou - is there no way you can get some real info logged to debug.txt?

-- TWiki:Main.SvenDowideit - 22 Oct 2008

I set up an account for Gilmar a while ago, but he still needs to find more time smile

-- Foswiki:Main.SvenDowideit - 12 Dec 2008

Thank you very much, Sven! I finally had the time today to work on this issue, and as I told you at IRC:
  • Symlinks doesn't work (they lead to 500 - Internal Server Error instead of 403 - Forbidden)
  • Scripts can't have -T switch, probably cause they're called without it in first place, then when perl finds it on shebang it refuses to run

Both situations give no chance to log anything frown, sad smile

I renamed foswiki_fastcgi to foswiki.fcgi to make things easier to users (most hosted environments and even webservers recognize FastCGI applications by that extension).

Unfortunately Dream Host users still need the .htaccess settings described above. I added a fix to PATH_INFO handling in that situations. An alternative would be to have all bin scripts be replaced by fast-cgi versions by FastCGIEngineContrib and provide some fix to CLI use case, like the one that exists in CGI, but I think it would be more problematic than the .htaccess setup. So, my suggestion is to add a .htaccess example to documentation (I'll do this later).

The -T issue bothers me. Please verify that with Dream Host guys.

Another (easier) option to configure is:
# .htaccess
RewriteEngine On
RewriteCond %{REQUEST_URI} !/configure
RewriteCond %{REQUEST_URI} !/foswiki.fcgi
RewriteRule ^(.*) foswiki.fcgi/$1 [L]

I added a hack to force execution with -T switch, even if it was not set by the webserver.

I just tried the above on a trun checkout on dreamhost, and get 500 still.

-- SvenDowideit - 19 Feb 2009

That's strange, cause I use this config and things work. Check http://gilmar.home.org.au/fcgi/Sandbox/FastCGITest and http://gilmar.home.org.au/cgi/Sandbox/FastCGITest. Both are trunk checkouts. The first is configured to run with FastCGI and the second as plain CGI.

Notice that even with Options +FollowSymLinks, symlinks doesn't work, so I pseudo-installed FastCGIEngineContrib with -copy instead of -link. Access mode of bin/foswiki.fcgi is 0755 (-rwx-r-xr-x).

-- GilmarSantosJr - 13 Apr 2009

here's what i used in bin/.htaccess to get FastCGIEngineContrib working on dreamhost:

#SetHandler cgi-script
SetHandler fastcgi-script
AddHandler fastcgi-script .fcgi
RewriteEngine on
RewriteCond %{REQUEST_URI} !/configure
RewriteCond %{REQUEST_URI} !/foswiki.fcgi
RewriteRule ^(.*) /wiki/bin/foswiki.fcgi/$1

please confirm and then we can update the docs in Item1315

-- WillNorris - 25 Jan 2010

Thanks for the feedback, Will!

Please, try to replace the line

RewriteRule ^(.*) /wiki/bin/foswiki.fcgi/$1

by

RewriteRule ^(.*) foswiki.fcgi/$1 [L]

(notice the relative path to foswiki.fcgi and the [L] flag) and report if it still works.

-- GilmarSantosJr - 25 Jan 2010

nice! it does work, and is obviously much cleaner. here is the updated config:

#SetHandler cgi-script
SetHandler fastcgi-script
RewriteEngine on
RewriteCond %{REQUEST_URI} !/configure
RewriteCond %{REQUEST_URI} !/foswiki.fcgi
RewriteRule ^(.*) foswiki.fcgi/$1 [L]

-- WillNorris - 25 Jan 2010

Only to keep records:

the configure part you are proposing is redundant because the configure section already has SetHandler cgi-script (i was only posting the necessary changes to an existing bin/.htaccess file to go from CGI to FastCGI? . (and, of course, it should be configure.*)

i was able to remove AddHandler (it's actually a shame that i couldn't use that instead of SetHandler, but that didn't work on dreamhost frown ).

-- WillNorris - 25 Jan 2010 (Support.Question201)

-- GilmarSantosJr - 25 Jan 2010

i use this on dreamhost all the time and distribute these lines with FoswikiOnLinuxSharedHostCommandShell, so i will relieve sven from confirmation and close this.

-- WillNorris - 27 Oct 2010
Topic revision: r18 - 08 Jun 2015, GilmarSantosJr
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy