You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Bojan Smojver <bo...@rexursive.com> on 2002/07/26 05:25:15 UTC

ForwardDirectories option with mod_jk 1.2.0/Apache 1.3.x

As some of you might have noticed, this option does nothing at the moment in
mod_jk 1.2.0/Apache 1.3.x. In mod_jk 1.2.0/Apache 2.0.x, all directory requests
not satisfied by static file lookup of mod_dir will be forwarded to the default
worker of Tomcat, if this option is set.

I have spent some time trying to implement the same behaviour in the version for
Apache 1.3.x, but without much luck. In order to gather ideas, I'll present
scenarios that I have investigated.

1. Make jk_handler a DIR_MAGIC_TYPE handler

This option creates problems due to the fact that jk_handler can (and my tests
show it will) be called before mod_dir. This then creates a behaviour in which
mod_dir isn't even given a chance to investigate if there are static files to
satisfy the directory request. Such situation is unacceptable as it would force
Tomcat to serve files like index.php or index.pl.

I'm not sure how to control the order of handler calls in Apache 1.3.x. Isn't
that the case that depends on the order of module loading? Apache 2.0.x, with
it's implementation of hooks, is a much more flexible platform.

2. Make explicit request from jk_fixups (new function)

I'm not even sure that this is the right place to put such a thing, but it
occurred to me that we need to know that all static files have been tried out.
The 'try out' happens in jk_translate as a sub-request done by mod_dir. We could
check if the last of the files from DirectoryIndex has been checked in jk_fixups
 and then make an explicit request by setting the worker to the default worker.
Regular request logic would then apply in jk_handler.

Alternatively, the above would be done in jk_translate (if ap_sub_req_lookup_uri
doesn't actually engage fixups). In any case, I'm not sure how the above would
affect mod_dir and it's order of processing.

Keep in mind that this analysis was done by a person that started reading about
Apache API only a few days ago. Any input appreciated, code preferred ;-)

Bojan

PS. If release of mod_jk 1.2.0 is something that needs to happen rather soon, I
don't think we should wait for this to be implemented as it doesn't seem like a
straightforward issue (at least not to me). So, version 1.2.0 can be released as
is now, with ForwardDirectories a no-op in Apache 1.3.x version, or we can wait
until this is resolved and then release.

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: ForwardDirectories option with mod_jk 1.2.0/Apache 1.3.x

Posted by Bojan Smojver <bo...@rexursive.com>.
Quoting Bojan Smojver <bo...@rexursive.com>:

> 2. Make explicit request from jk_fixups (new function)

Actually, this would break Apache completely, because serving requests from
non-handlers is not allowed. However...

I have developed solution for this problem involving this:
-----------------------------------
- declare:

extern module dir_module;

- copy the typedef from mod_dir:

typedef struct dir_config_struct {
    array_header *index_names;
} dir_config_rec;

- introduce jk_fixups function (this runs after jk_translate):
  - this function checks if this is a sub-request, and if yes
  - checks if ForwardDirectories is set, and if yes
  - then it determines if this is the last file mentioned in DirectorIndex
  - if yes and still no worker is set (i.e. we exhausted all index options)
    - sets r->uri=r->main->uri (the directory in question)
    - sets r->finfo.st_mode=S_IFREG, to trick mod_dir to serve
    - sets r->main->handler to JK_HANDLER

- jk_translate gets these changes:
  - if map_uri_to_worker can't find the worker and
  - if r->prev exists and
  - if r->prev->handler is JK_HANDLER and
  - if r->uri is a directory
    - picks the default worker, which then causes the request to go to Tomcat
-----------------------------------

The dirty part is:

- mod_jk would depend on mod_dir being present
- one typedef from mod_dir is copied into mod_jk

I'd like to get comments on this before I commit. I have tested this fix and it
works, but I wouldn't like to introduce a solution that breaks things for some
people or is too ugly. mod_dir is a standard module and it gets compiled in by
default, so I don't think there would be too many people without it. However,
there is always an odd configuration somewhere...

There are also other, minor changes to the code, like making sure that the
structure holding worker_env isn't freed straight after it gets created. We now
need it later to determine the default worker in case we are forwarding directories.

Bojan

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: ForwardDirectories option with mod_jk 1.2.0/Apache 1.3.x

Posted by Henri Gomez <hg...@apache.org>.
Quoting Bojan Smojver <bo...@rexursive.com>:

> As some of you might have noticed, this option does nothing at the moment in
> mod_jk 1.2.0/Apache 1.3.x. In mod_jk 1.2.0/Apache 2.0.x, all directory
> requests
> not satisfied by static file lookup of mod_dir will be forwarded to the
> default
> worker of Tomcat, if this option is set.


> PS. If release of mod_jk 1.2.0 is something that needs to happen rather soon,
> I
> don't think we should wait for this to be implemented as it doesn't seem like
> a
> straightforward issue (at least not to me). So, version 1.2.0 can be released
> as
> is now, with ForwardDirectories a no-op in Apache 1.3.x version, or we can
> wait
> until this is resolved and then release.

No, I think it's better to delay it. I'll be on holidays next 3 weeks so it'll
have to wait my come back and the mod_dir fixes :)

Regards

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>