Lighttpd + FastCGI + RT - Broken CSS / Menu Items Dont Work

Hello,

Once again it appears I’ve run into a snag. I’m running lighttpd with RT
on CentOS 5.4. This is my first attempt at trying to get RT to run under
lighttpd with FastCGI. When I open the RT URL in my browser, everything
is flush left and the only image shown anywhere on the page is the best
practical logo. There are no colors on the page at all aside from the
links themselves. My first thought was that there must be a missing CSS
file. So I first hunted through the access.log for lighttpd only to find
a status code 200 on everything. This implies the web server was able to
provide my browser all files.

I next logged into the interface, and was presented with what appears to
be the dashboard, and logged in user menu. Again, no colors, no
formatting on the page. Appears as if some CSS file somewhere is
missing. I discovered that none of the menu items(Simple Search,
Tickets, Tools, Configuration, Preferences, etc) work. When I click
them, the URL changes, however I continue to only be shown the homepage
in my browser.

I double checked all the examples I could find online and my
lighttpd.conf appears to be correct. I feel I’m at a loss here. If
anyone can provide some help on this one, I’d appreciate it.

The best that I seem to be able to determine is that it’s probably
something wrong in the lighttpd’s mod_rewrite configuration as it seems
to be redirecting what should be static URL’s to the homepage.

Here is my lighttpd.conf file:
server.modules = (
“mod_rewrite”,
“mod_redirect”,
“mod_alias”,
“mod_access”,
“mod_cml”,
“mod_trigger_b4_dl”,
“mod_auth”,
“mod_status”,
“mod_setenv”,
“mod_fastcgi”,
“mod_proxy”,
“mod_simple_vhost”,
“mod_evhost”,
“mod_userdir”,
“mod_cgi”,
“mod_compress”,
“mod_ssi”,
“mod_usertrack”,
“mod_expire”,
“mod_secdownload”,

“mod_rrdtool”,

                            "mod_accesslog" )

server.document-root = “/srv/www/lighttpd/”
server.errorlog = “/var/log/lighttpd/error.log”
index-file.names = ( “index.php”, “index.html”,
“index.htm”, “default.htm” )
mimetype.assign = (
“.rpm” => “application/x-rpm”,
“.pdf” => “application/pdf”,
“.sig” => “application/pgp-signature”,
“.spl” => “application/futuresplash”,
“.class” => “application/octet-stream”,
“.ps” => “application/postscript”,
“.torrent” => “application/x-bittorrent”,
“.dvi” => “application/x-dvi”,
“.gz” => “application/x-gzip”,
“.pac” => “application/x-ns-proxy-autoconfig”,
“.swf” => “application/x-shockwave-flash”,
“.tar.gz” => “application/x-tgz”,
“.tgz” => “application/x-tgz”,
“.tar” => “application/x-tar”,
“.zip” => “application/zip”,
“.mp3” => “audio/mpeg”,
“.m3u” => “audio/x-mpegurl”,
“.wma” => “audio/x-ms-wma”,
“.wax” => “audio/x-ms-wax”,
“.ogg” => “application/ogg”,
“.wav” => “audio/x-wav”,
“.gif” => “image/gif”,
“.jar” => “application/x-java-archive”,
“.jpg” => “image/jpeg”,
“.jpeg” => “image/jpeg”,
“.png” => “image/png”,
“.xbm” => “image/x-xbitmap”,
“.xpm” => “image/x-xpixmap”,
“.xwd” => “image/x-xwindowdump”,
“.css” => “text/css”,
“.html” => “text/html”,
“.htm” => “text/html”,
“.js” => “text/javascript”,
“.asc” => “text/plain”,
“.c” => “text/plain”,
“.cpp” => “text/plain”,
“.log” => “text/plain”,
“.conf” => “text/plain”,
“.text” => “text/plain”,
“.txt” => “text/plain”,
“.dtd” => “text/xml”,
“.xml” => “text/xml”,
“.mpeg” => “video/mpeg”,
“.mpg” => “video/mpeg”,
“.mov” => “video/quicktime”,
“.qt” => “video/quicktime”,
“.avi” => “video/x-msvideo”,
“.asf” => “video/x-ms-asf”,
“.asx” => “video/x-ms-asf”,
“.wmv” => “video/x-ms-wmv”,
“.bz2” => “application/x-bzip”,
“.tbz” => “application/x-bzip-compressed-tar”,
“.tar.bz2” => “application/x-bzip-compressed-tar”,

default mime type

“” => “application/octet-stream”,
)

accesslog.filename = “/var/log/lighttpd/access.log”
url.access-deny = ( “~”, “.inc” )

$HTTP[“url”] =~ “.pdf$” {
server.range-requests = “disable”
}
static-file.exclude-extensions = ( “.php”, “.pl”, “.fcgi” )
server.pid-file = “/var/run/lighttpd.pid”
server.username = “lighttpd”
server.groupname = “lighttpd”

$HTTP[“host”] =~ “rt.sagonet.com” {

Specify the documentroot

server.document-root = “/opt/rt3/share/html”

Map appropriate files and extensions

fastcgi.map-extensions = ( “.css” => “.html”, “.js” => “.html”, “/” =>
“.html”, “mail-gateway” => “.html”, “Search/Chart” => “.html”,
“Search/Results.rdf” => “.html”, “Search/Results.tsv” => “.html” )

Set Lighttpd to check for an index.html file for each directory

index-file.names = ( “index.html” )

Disallow access to .mhtml files

url.access-deny = ( “.mhtml” )

setenv.add-environment = (
“SCRIPT_NAME” => “/”,
)

Set up an alias for the /NoAuth/images location

url.rewrite-once = (
“^/(?!NoAuth/images/)(.)" => “/$1”,
"^(.
)/Ticket/Attachment/(.*)” => “/$1/Ticket/Attachment/$2/”
)

Set up FastCGI handler

fastcgi.server = ( “.html” =>
((
“socket” => “/tmp/request-tracker.socket”,
“check-local” => “disable”,
“bin-path” => “/opt/rt3/bin/mason_handler.fcgi”,
“min-procs” => 2,
“max-procs” => 2
)),

)

}

thank you

Max Rathbone

Again discovered the solution to my problem. I previously compiled RT
with FastCGI and was trying to display it with mod_perl2.

Recompile of RT with the correct handler fixed the problem.

Thanks

Max

Maxwell Rathbone wrote:

Okay I take this back… not sure what I was thinking… Guess I got
confused between my attempts with lighttpd and just trying to prove it
works through Apache.

This problem is still unresolved unfortunately. I did recompile RT with
the right handler, and none of the menu items or links work. It seems as
if the handler is not properly handling sub directories??

Weird thing is, I’ve been looking at RT in Chrome and Firefox… when I
turned off Apache and turned on lighttpd, the CSS retained in my
browser. PResumably because it was cached. In IE, the lighttpd instance
of my RT still continues to not have any CSS formatting or colorization.
(In addition to the menu items and links not working)

Max

Maxwell A. Rathbone wrote:

After over a day trying to get lighttpd + FastCGI working… I FINALLY
found the last major problem.

The mason handler that is provided with RT 3.8.6(mason_handler.fcgi) is
NOT COMPATIBLE with lighttpd. It works perfectly fine for Apache. The
numerous mason_lighttpd_handler.fcgi scripts that are found online all
have a code error in them that causes lighttpd to crash. So they are
invalid as well. (Easily verifiable and reproducable)

It appears the underlying problem with the built-in mason_handler.fcgi
is that the CGI::Fast call is not able to properly deduce the current
URL that is being pulled up. This value should be stored into
$cgi->path_info.

I found an article from 2006(yes, I said, 2006) where someone posted a
diff between the built-in handler and what he found finally worked. I
applied the changes to my handler, and after a quick restart of lighttpd
it started showing my RT instance properly with colors, CSS, and all
menu items work.

It appears that this problem/bug has persisted for at least three years.
This may explain why there is such little information on lighttpd +
FastCGI and getting it to work properly. I’m posting the corrected
handler here, and will post it as a bug as well so hopefully Best
Practical can provide the lighttpd handler in future releases of RT as well.

In case anyone stumbles onto this thread in the future, here is my
complete mason handler code:
#!/usr/bin/perl

BEGIN BPS TAGGED BLOCK {{{

COPYRIGHT:

This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC

jesse@bestpractical.com

(Except where explicitly superseded by other copyright notices)

LICENSE:

This work is made available to you under the terms of Version 2 of

the GNU General Public License. A copy of that license should have

been provided with this software, but in any event can be snarfed

from www.gnu.org.

This work is distributed in the hope that it will be useful, but

WITHOUT ANY WARRANTY; without even the implied warranty of

MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU

General Public License for more details.

You should have received a copy of the GNU General Public License

along with this program; if not, write to the Free Software

Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA

02110-1301 or visit their web page on the internet at

GNU General Public License v2.0 - GNU Project - Free Software Foundation.

CONTRIBUTION SUBMISSION POLICY:

(The following paragraph is not intended to limit the rights granted

to you to modify and distribute this software under the terms of

the GNU General Public License and is only of importance to you if

you choose to contribute your changes and enhancements to the

community by submitting them to Best Practical Solutions, LLC.)

By intentionally submitting any modifications, corrections or

derivatives to this work, or any other work intended for use with

Request Tracker, to Best Practical Solutions, LLC, you confirm that

you are the copyright holder for those contributions and you grant

Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,

royalty-free, perpetual, license to use, copy, create derivative

works based on those contributions, and sublicense and distribute

those contributions and any derivatives thereof.

END BPS TAGGED BLOCK }}}

package RT::Mason;

use strict;
use vars ‘$Handler’;
use File::Basename;

require (dirname(FILE) . ‘/webmux.pl’);

Enter CGI::Fast mode, which should also work as a vanilla CGI script.

require CGI::Fast;

RT::Init();
$Handler ||= RT::Interface::Web::Handler->new(
RT->Config->Get(‘MasonParameters’)
);

while ( my $cgi = CGI::Fast->new ) {
# the whole point of fastcgi requires the env to get reset here…
# So we must squash it again
$ENV{‘PATH’} = ‘/bin:/usr/bin’;
$ENV{‘CDPATH’} = ‘’ if defined $ENV{‘CDPATH’};
$ENV{‘SHELL’} = ‘/bin/sh’ if defined $ENV{‘SHELL’};
$ENV{‘ENV’} = ‘’ if defined $ENV{‘ENV’};
$ENV{‘IFS’} = ‘’ if defined $ENV{‘IFS’};

my $uri = $ENV{REQUEST_URI};
if ($uri =~ /\?/) {
  $uri =~ /^(.*?)\?(.*)/;
  $ENV{PATH_INFO} = $1;
  $ENV{QUERY_STRING} = $2;
} else {
  $ENV{PATH_INFO} = $uri;
  $ENV{QUERY_STRING} = "";
}


Module::Refresh->refresh if RT->Config->Get('DevelMode');
RT::ConnectToDatabase();

if ( ( !$Handler->interp->comp_exists( $cgi->path_info ) )
    && ( $Handler->interp->comp_exists( $cgi->path_info . 

“/index.html” ) ) ) {
$cgi->path_info( $cgi->path_info . “/index.html” );
}

eval { $Handler->handle_cgi_object($cgi); };
if ($@) {
    $RT::Logger->crit($@);
}
RT::Interface::Web::Handler->CleanupRequest();

}

1;

Max Rathbone

Maxwell A. Rathbone wrote: