Project

General

Profile

[Solved] Trouble with mod_rewrite after update to 1.4.40

Added by R00KIE almost 8 years ago

I've been using lighttpd to serve selfoss (a feed reader) and I have stumbled upon a problem after the update to lighttpd 1.4.40. When I try to access the server all I get is error 404. This is definitely connected with lighttpd as downgrading only lighttpd to 1.4.39 makes things work again.

I'm using ArchLinux ARM fully up to date on a raspberry pi, with lighttpd 1.4.40, php 7.0.8 and php-cgi 7.0.8 and selfoss 2.15. My server configuration is as follows:

server.port = 9090
server.document-root = "/usr/share/webapps/selfoss" 
server.errorlog = "/var/log/lighttpd/error.log" 
dir-listing.activate = "disable" 
index-file.names = ( "index.php" )
server.modules += ( "mod_rewrite", "mod_cgi" )
cgi.assign = ( ".php" => "/usr/bin/php-cgi" )
url.rewrite-once = (
  "^/public/.*$" => "$0",
  "^/favicon.ico$" => "/public/favicon.ico",
  "^/favicons/(.*)$" => "/data/favicons/$1",
  "^/thumbnails/(.*)$" => "/data/thumbnails/$1",
  "^/(.*.(js|ico|gif|jpg|png|css|asc|txt|eot|woff|ttf|svg))$" => "/public/$1",
  "^/index.php(.*)$" => "$0",
  "^/([^\?]*)(\?(.*))?" => "/index.php?$3",
  "^/(.*)" => "/index.php$1" 
)
include "/usr/share/doc/lighttpd/config/conf.d/mime.conf" 

I have (maybe) narrowed the problem to the rewrite rules, if I omit the last three rules I can get selfoss to work partially. However this item: "mod_cgi handles local redirect response if Location: /path?query" in the changelog also seems a possible culprit.

I'm completely out my depth here and I would appreciate if someone could point me in the right direction or provide some help.


Replies (7)

RE: Trouble with mod_rewrite after update to 1.4.40 - Added by gstrauss almost 8 years ago

It is possible that the issue you are seeing is related to a change/bug in REQUEST_URI. See https://redmine.lighttpd.net/issues/2738

RE: Trouble with mod_rewrite after update to 1.4.40 - Added by R00KIE almost 8 years ago

I have tried to bisect this but I suspect I didn't catch the offending commit as the first bad one doesn't compile (some other along the way also fail).

Are there any simple tests I can do or logs I can provide that might help get to the bottom of the problem?

Bisect log:

# bad: [268c5582b2a2bb1336aa656eb533c37ce0353b87] [doc] NEWS
# good: [c27e27a51bca703da6ff289d629956ae20699b0f] [scons] fix fullstatic build
git bisect start 'lighttpd-1.4.40' 'lighttpd-1.4.39'
# bad: [a3d4aa9f23697d222fda7041ba9fee207f4cde1f] server.error-handler new directive for error pages
git bisect bad a3d4aa9f23697d222fda7041ba9fee207f4cde1f
# good: [cc81f1f9dc68327e8bb4a7cecf6a26fcc3054b49] add NEWS entry for previous commit
git bisect good cc81f1f9dc68327e8bb4a7cecf6a26fcc3054b49
# good: [bb95317774023dcbfaaeaeb635942ec15f17c3d8] [core] setrlimit max-fds <= rlim_max for non-root (fixes #2723)
git bisect good bb95317774023dcbfaaeaeb635942ec15f17c3d8
# bad: [2f21aaa973a902ee237a9894bdedd6c82c8edfe2] handlers can read response before sending req body (fixes #131, #2566)
git bisect bad 2f21aaa973a902ee237a9894bdedd6c82c8edfe2
# good: [77bd45121cd50ca317b3daed5b5b1a567a79b315] [core] retry tempdirs on partial write, ENOSPC (fixes #2588)
git bisect good 77bd45121cd50ca317b3daed5b5b1a567a79b315
# bad: [635ab6f802c709c34b2cb095eae70dadd434f6ea] mv funcs from connections.c to connections-glue.c
git bisect bad 635ab6f802c709c34b2cb095eae70dadd434f6ea
# good: [c263bc6a119faa52a2e2ffd65bb986213fd5280e] defer reading request body until handle subrequest (fixes #2541)
git bisect good c263bc6a119faa52a2e2ffd65bb986213fd5280e
# first bad commit: [635ab6f802c709c34b2cb095eae70dadd434f6ea] mv funcs from connections.c to connections-glue.c

This corresponds to: build fail, good, good, build fail, good, build fail, good.

RE: Trouble with mod_rewrite after update to 1.4.40 - Added by gstrauss almost 8 years ago

I just downloaded selfoss and was able to reproduce the issue. As I suspected, it is the same issue as https://redmine.lighttpd.net/issues/2738 I'm still digging into this...

RE: Trouble with mod_rewrite after update to 1.4.40 - Added by R00KIE almost 8 years ago

That's good that you can reproduce the problem as I'm way out of my depth here, I'll keep an eye on the bug report.

There is something else, if you are using php7 the current selfoss git needs a fix to work.


sed -i "1185s/(\$this/(\$fw/" libs/f3/base.php
sed -i "1186s/this/fw/" libs/f3/base.php

RE: Trouble with mod_rewrite after update to 1.4.40 - Added by gstrauss almost 8 years ago

As in #2738, short-term workaround in lighttpd 1.4.40 is to edit common.php in the selfoss directory and put the following at the top, after the line <?php

if ( !empty( $_SERVER['REDIRECT_URI'] )
  && isset(  $_SERVER['SERVER_SOFTWARE'] )
  && strpos( $_SERVER['SERVER_SOFTWARE'], 'lighttpd') === 0 ) {
    $_SERVER['REQUEST_URI'] = $_SERVER['REDIRECT_URI'];
}

RE: Trouble with mod_rewrite after update to 1.4.40 - Added by R00KIE almost 8 years ago

That does the trick :)

I'll run selfoss with this quick fix and lighttpd 1.4.40 and if I see anything else that might look out of place I'll drop a new reply here.

RE: Trouble with mod_rewrite after update to 1.4.40 - Added by gstrauss almost 8 years ago

As noted in #2738:

FYI: there will be a release of lighttpd 1.4.41 in the next two weeks (and possibly before end of July), which reverts this change made in lighttpd 1.4.40.

    (1-7/7)