Project

General

Profile

Actions

Bug #115

closed

Unwanted redirection when using ssl.

Added by Anonymous about 19 years ago. Updated over 17 years ago.

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

Description

I am having a strange issue.
I have two instances of lighttpd running, started from the same binary, but using different config files. One serves ssl, the other regular http traffic.

When I type a url, or click a link with a url, of the form https://domain.net/subdir it redirects to http://domain.net/subdir/

note the lack of a trailing / in the first https url. If the trailing slash is added, then the correct directory is retrieved. For some reason, if there is no tailing url, it seems to be rewriting the url improperly (ie. rewriting without the https).

the modules I have loaded on the ssl instance are:
mod_access
mod_auth
mod_status
mod_cgi
mod_compress
mod_accesslog

ssl is also active on that instance..

-- eliott


Files

Screenshot-Ddd.png (38.3 KB) Screenshot-Ddd.png Screenshot of a ddd debug session -- eliott Anonymous, 2005-05-07 23:52
connections.diff (321 Bytes) connections.diff Anonymous, 2005-05-12 09:48
Actions #1

Updated by Anonymous about 19 years ago

It appears to be very similar (identical?) to the bug here: http://trac.lighttpd.net/trac/ticket/35
Apparently it is still happening.

-- eliott

Actions #2

Updated by Anonymous about 19 years ago

Seems to be stemming from a check in http-header-glue.c, in the function http_response_redirect_to_directory. The check is of con->conf.is_ssl. It is set to 0 even when ssl is being used and port 443.

It is effecting the following block of code:


if (con->conf.is_ssl) {
   buffer_copy_string(o, "https://");
} else {
   buffer_copy_string(o, "http://");
}

A backtrace to the call yeilds:


#0  http_response_redirect_to_directory (srv=0x8154008, con=0x81689b0) at http-header-glue.c:105
#1  0x0804fdc9 in http_response_prepare (srv=0x8154008, con=0x81689b0) at response.c:1205
#2  0x0805240b in connection_state_machine (srv=0x8154008, con=0x81689b0) at connections.c:1222
#3  0x0804d5cd in main (argc=9, argv=0x81689b0) at server.c:982

This only happens when in http_response_prepare a check for the uri request ending in a / is performed.


if (con->physical.path->ptr[con->physical.path->used - 2] != '/') 

I am not sure why con->conf.is_ssl is being set to 0. If that is resolved, then the subsequent code should work as designed. ie. a rewrite to https instead of http.

-- eliott

Actions #3

Updated by Anonymous almost 19 years ago

I think I tracked down the problem with some heavy duty debugging...
I attached a screenshot to highlight what seems to be the issue.

At line 1143 in connections.c, when SSL_set_accept_state(con->ssl); is done, con->is_ssl is not set. con->is_ssl is later tested in http-header-glue.c to determine if the rewrite is to http or https.

Shouldn't con->is_ssl be getting set in connections.c after a successful SSL accept?

-- eliott

Actions #4

Updated by Anonymous almost 19 years ago

I think I found the fix for the issue. I have attached a diff of the change. It is one line in connections.c.

-- eliott

Actions #5

Updated by Anonymous almost 19 years ago

The diff is against the 1.3.13 version.

-- eliott

Actions #6

Updated by jan almost 19 years ago

  • Status changed from New to Fixed
  • Resolution set to fixed

The patch has been applied as r367 with some minor cosmetics.

Actions

Also available in: Atom