views:

569

answers:

2

Apache is spitting out a HTTP response of code: 400 "Bad Request" with no details whenever I access a page driven that is handled by a FastCGI script.

  • I've installed the mod_fcgid module and it's loaded and configured in the Apache config files
  • I've tested several FastCGI scripts, all of them run when directly executed.
  • Static resources are served appropriately.
  • Apache is trying to launch the script because it complains when I rewrite the URL to a non-existant script

Anyone have any idea what's wrong with my Apache Config?

<VirtualHost ip.ad.re.ss:80>
  ServerName   demo.domain.com:80 

  DocumentRoot /var/www/vhosts/domain.com/subdomains/demo/rails/public
  CustomLog  /var/www/vhosts/domain.com/statistics/logs/demo_access_log combined
  ErrorLog  /var/www/vhosts/domain.com/statistics/logs/demo_error_log
  LogLevel info
  Options +FollowSymLinks +ExecCGI -SymLinksIfOwnerMatch
  AddHandler fcgid-script .fcgi

  RewriteEngine On
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
</VirtualHost>

EDIT -- I've checked the mod_rewrite logs and URI's are being rewritten correctly

A: 

Try removing the DOCUMENT_ROOT rewrite cond. Second, checkout the mod_rewrite log directives, they're extremely informative as far as weird issues like this.

David
They were very informative and I did have some stuff wrong. The rewriting is working correctly now, but I'm still getting a 400 error. rewrite logs: RewriteCond: input='/path/to/app/public/' pattern='!-f' => matchedrewrite '/' -> 'dispatch.fcgi'local path result: dispatch.fcgi
Daniel Beardsley
A: 

Alright, one more thing to try.
http://httpd.apache.org/docs/2.2/mod/core.html#loglevel.

Set the log level to debug and make sure this is not on a production machine because it produces a lot of output per individual event (get/put).

I think how your example above of FastCGI is missing something, but I admit its been a while since I've done anything but php or python fastcgi.
What language is dispatch.fcgi in? Can you execute it from the command line and does Apache have permission to execute the file? ( sudo su apacheaccount ).

Update: Knew you were missing something: check out -> http://fastcgi.coremail.cn/configuration.htm FCGIWrapper is needed to tell fast cgi what to use to execute your dispatch.fcgi file.

David
Thanks for trying. I changed the LogLevel, but the error log is empty and the access log is normal because Apache doesn't treat it as an error I think.It's in ruby, and yeah, the dispatch.fcgi is executable and readable by everyone.
Daniel Beardsley
Oh, and yeah, dispatch.fcgi still executes fine from the command line
Daniel Beardsley
Knew you were missing something: check out -> http://fastcgi.coremail.cn/configuration.htmFCGIWrapper is needed to tell fast cgi what to use to execute your dispatch.fcgi file.
David