Project

General

Profile

Actions

Feature #1749

closed

Make lighty.request fully writable in mod_magnet

Added by Anonymous over 15 years ago. Updated 3 months ago.

Status:
Fixed
Priority:
Normal
Category:
mod_magnet
Target version:
-
ASK QUESTIONS IN Forums:
No

Description

Without this patch changes in lighty.request table don't go outside of mod_magnet.

Test case:
revproxy.lua:


lighty.request["Host"] = lighty.request["X-Forwarded-Host"]

index.cgi:


#! /usr/bin/perl
print "Content-Type: text/plain\n\n";

for (keys %ENV) {
        print $_, " => ", $ENV{$_}, "\n";
}

GET -H 'X-Forwarded-Host: www.example.com' !http://172.30.0.65/cgi/index.cgi

Request result (without patch):
HTTP_HOST => 172.30.0.65

Request result (with patch):
HTTP_HOST => www.example.com

This patch is really useful (together with mod_extforward) for lighttpd servers behind reverse proxy. In this scenario proxy adds special header (ex. X-Forwarded-Host:) with original Host: value and forwards requests to lighttpd.
Some CGI applications that depends on "correct" Host: header can work without modifications.

-- kupson


Files

Actions #1

Updated by stbuehler over 15 years ago

I am not convinced yet that it should be writable from mod_magnet; for example you ignore the fact that the hostname is used in conditionals.

Actions #2

Updated by stbuehler over 15 years ago

  • Target version changed from 1.4.20 to 1.4.21
Actions #3

Updated by icy about 15 years ago

  • Target version changed from 1.4.21 to 1.4.22
  • Patch available set to Yes
Actions #4

Updated by stbuehler about 15 years ago

  • Target version changed from 1.4.22 to 1.4.23
Actions #5

Updated by stbuehler almost 15 years ago

  • Status changed from New to Wontfix

If someone needs this feature, he has to apply that path himself. I think it is too dangerous.
And a proxy shouldn't modify the Host: header imho (unless you really want that, in which case you don't want to revert the change).

Actions #6

Updated by gstrauss 3 months ago

  • Status changed from Wontfix to Fixed
  • Target version deleted (1.4.23)
  • ASK QUESTIONS IN Forums set to No

lighttpd 1.4.60 mod_magnet allows modifications to lighty.r.req_header[], but mod_magnet doc warns:

lighty.r.req_header[] allows get/set of request headers
If modifications would affect config processing, script should return
lighty.RESTART_REQUEST to have lighttpd restart the modified request.

and the script would have to avoid looping after the request processing restart, e.g. by checking if lighty.r.req_header["Host"] == lighty.r.req_header["X-Forwarded-Host"]

Actions

Also available in: Atom