Apache Lounge



Forum Index Downloads Search Register Log in  RSS Apache Lounge

Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.



A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Apache Lounge is not sponsored by anyone.

Your donations will help to keep this site alive and well, and continuing the building of the binaries.

Module Loading Order for Apache 2

Post new topic   Reply to topic    Apache Forum Index -> Apache

View previous topic :: View next topic  
Author Message

Joined: 24 Mar 2009
Posts: 14

PostPosted: Sun 12 Jul '09 5:14    Post subject: Module Loading Order for Apache 2 Reply with quote


I am having some trouble. Mod_Rewrite is loading and executing before Mod_Security and a custom module I wrote. I need variables set by Mod_Security and my custom module for Mod_Rewrite.

Not sure which configuration file you need me to post

Back to top
James Blond

Joined: 19 Jan 2006
Posts: 5627
Location: Germany, Next to Hamburg

PostPosted: Thu 13 Aug '09 20:19    Post subject: Reply with quote

A maybe nerfing solution is to start apache in debug mode so you can see when which module loads. I'm note sure if it makes a difference to change the loading order in httpd.conf
Back to top

Joined: 16 Oct 2007
Posts: 1903
Location: Sun Diego, CA, USofA

PostPosted: Thu 13 Aug '09 21:39    Post subject: Reply with quote

It does look like they load in order to me
Back to top

Joined: 17 Dec 2005
Posts: 610
Location: Milford, MA, USA

PostPosted: Fri 14 Aug '09 4:21    Post subject: Reply with quote

If you assign something to the environment variable SHOW_HOOKS and then start Apache from the command line, it will display the sorting of modules for each hook. Note that this is an OS-environment variable that you set on the command line, not an Apache-environment variable that you set in httpd.conf.
For example:
httpd.exe -t

If you use mod_info, another way to see this is to browse to http://localhost/server-info#request_hooks.

In your custom module code, you should pass a NULL-terminated string array of the modules that you want to load before and after your module in your call to ap_hook_whatever. For example, if you use the "fixups" hook:
static const char * const aszPre[] ={ "mod_security2.c", NULL };
static const char * const aszPost[]={ "mod_rewrite.c", NULL };
ap_hook_fixups(my_fixup, aszPre, aszPost, APR_HOOK_MIDDLE);

Nick Kew's book on Apache Modules explains this stuff well. Recommended if you want to write your own Apache modules.

Back to top

Post new topic   Reply to topic    Apache Forum Index -> Apache
Page 1 of 1