| 1 | # |
|---|
| 2 | # $Id$ |
|---|
| 3 | # |
|---|
| 4 | package CatalystX::Plugin::Engine::FastCGI::Lighttpd; |
|---|
| 5 | use strict; |
|---|
| 6 | use warnings; |
|---|
| 7 | use utf8; |
|---|
| 8 | use version; our $VERSION = qv('0.0.2'); |
|---|
| 9 | |
|---|
| 10 | use NEXT; |
|---|
| 11 | |
|---|
| 12 | sub handle_request { |
|---|
| 13 | my ( $c, %args ) = @_; |
|---|
| 14 | |
|---|
| 15 | my $env_ref = $args{env}; |
|---|
| 16 | |
|---|
| 17 | if ( ( $env_ref->{SERVER_SOFTWARE} || q{} ) !~ /lighttpd/msx ) { |
|---|
| 18 | $c->log->warn(__PACKAGE__ . ': Do you want to apply this really?'); |
|---|
| 19 | } |
|---|
| 20 | |
|---|
| 21 | if ( $c->engine ne 'Catalyst::Engine::FastCGI' ) { |
|---|
| 22 | $c->log->warn(__PACKAGE__ . ': Do you want to apply this really?'); |
|---|
| 23 | } |
|---|
| 24 | |
|---|
| 25 | ( $env_ref->{PATH_INFO}, $env_ref->{QUERY_STRING} ) = |
|---|
| 26 | ( split /\?/msx, $env_ref->{REQUEST_URI}, 2 ); |
|---|
| 27 | |
|---|
| 28 | $env_ref->{HTTP_X_FORWARDED_HOST} ||= $env_ref->{HTTP_X_HOST}; |
|---|
| 29 | |
|---|
| 30 | return $c->NEXT::handle_request(%args); |
|---|
| 31 | } |
|---|
| 32 | |
|---|
| 33 | 1; |
|---|
| 34 | |
|---|
| 35 | __END__ |
|---|
| 36 | |
|---|
| 37 | =head1 NAME |
|---|
| 38 | |
|---|
| 39 | CatalystX::Plugin::Engine::FastCGI::Lighttpd - Fix up for FastCGI on Lighttpd. |
|---|
| 40 | |
|---|
| 41 | =head1 VERSION |
|---|
| 42 | |
|---|
| 43 | This document describes CatalystX::Plugin::Engine::FastCGI::Lighttpd version 0.0.2 |
|---|
| 44 | |
|---|
| 45 | =head1 SYNOPSIS |
|---|
| 46 | |
|---|
| 47 | # 1. in your MyApp.pm |
|---|
| 48 | use Catalyst qw(+CatalystX::Engine::FastCGI::Lighttpd); |
|---|
| 49 | |
|---|
| 50 | # when lighttpd is behind proxy |
|---|
| 51 | __PACKAGE__->config( using_frontend_proxy => 1 ); |
|---|
| 52 | |
|---|
| 53 | # 2. in your lighttpd.conf |
|---|
| 54 | server.error-handler-404 = "DISPATCH_TO_CATALYST" |
|---|
| 55 | fastcgi.server = ( "DISPATCH_TO_CATALYST" => |
|---|
| 56 | (( "socket" => "/path/to/myapp.socket", |
|---|
| 57 | "bin-path" => "/usr/bin/perl /path/to/myapp_fastcgi.pl", |
|---|
| 58 | "check-local" => "disable" ))) |
|---|
| 59 | |
|---|
| 60 | =head1 DESCRIPTION |
|---|
| 61 | |
|---|
| 62 | C::E::FastCGI could not treat with PATH_INFO and QUERY_STRING correctly. |
|---|
| 63 | This module fix up it. |
|---|
| 64 | mod_proxy of Lighttpd does not set HTTP_X_FORWARDED_HOST. |
|---|
| 65 | This module fix up it. |
|---|
| 66 | |
|---|
| 67 | =head1 SUBROUTINES/METHODS |
|---|
| 68 | |
|---|
| 69 | =head2 handle_request( $c, %args ) |
|---|
| 70 | |
|---|
| 71 | It rebuild PATH_INFO and QUERY_STRING from REQUEST_URI. |
|---|
| 72 | |
|---|
| 73 | =head1 DIAGNOSTICS |
|---|
| 74 | |
|---|
| 75 | =over |
|---|
| 76 | |
|---|
| 77 | =item Do you want to apply this really? |
|---|
| 78 | |
|---|
| 79 | This module works only on fastcgi-lighttpd. |
|---|
| 80 | |
|---|
| 81 | =back |
|---|
| 82 | |
|---|
| 83 | =head1 CONFIGURATION AND ENVIRONMENT |
|---|
| 84 | |
|---|
| 85 | CatalystX::Plugin::Engine::FastCGI::Lighttpd requires no configuration files or environment variables. |
|---|
| 86 | |
|---|
| 87 | =head1 DEPENDENCIES |
|---|
| 88 | |
|---|
| 89 | None. |
|---|
| 90 | |
|---|
| 91 | =head1 INCOMPATIBILITIES |
|---|
| 92 | |
|---|
| 93 | None reported. |
|---|
| 94 | |
|---|
| 95 | =head1 BUGS AND LIMITATIONS |
|---|
| 96 | |
|---|
| 97 | No bugs have been reported. |
|---|
| 98 | |
|---|
| 99 | Please report any bugs or feature requests to |
|---|
| 100 | C<bug-catalystx-plugin-engine-fastcgi-lighttpd@rt.cpan.org>, or through the web interface at |
|---|
| 101 | L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=CatalystX-Plugin-Engine-FastCGI-Lighttpd>. |
|---|
| 102 | I will be notified, and then you'll automatically be notified of progress on |
|---|
| 103 | your bug as I make changes. |
|---|
| 104 | |
|---|
| 105 | =head1 AUTHOR |
|---|
| 106 | |
|---|
| 107 | Hironori Yoshida <yoshida@cpan.org> |
|---|
| 108 | |
|---|
| 109 | =head1 LICENSE AND COPYRIGHT |
|---|
| 110 | |
|---|
| 111 | This module is free software; you can redistribute it and/or |
|---|
| 112 | modify it under the same terms as Perl itself. See L<perlartistic>. |
|---|
| 113 | |
|---|
| 114 | =cut |
|---|