Mod_Log_Remote_Port

mod_log_remote_port

Download

Synopsis

The mod_log_remote_port module is based on the Blackbox Logs article I wrote for O'Reilly. I figured that since Apache still didn't have a native method to log the client port, and since some users may not want to recompile their HTTP build, I'd create a standalone apache module to handle the directive.

The code is under 100 lines, and the majority of the functionality was learned just by examining the code from the mod_logio module. It has been test built as a dynamic DSO using the apxs interface.

Shared Library Build

  1. Download the C file.
  2. Run apxs to compile the shared library.
    $ apxs -c mod_log_remote_port.c
    
  3. Configure apache
    LoadModule log_remote_port_module modules/mod_log_remote_port.so
    
  4. Log the remote port using the CustomLog directive
    LogFormat "%a/%S %X %t \"%r\" %s/%>s %{pid}P/%{tid}P %T/%D %I/%O/%B" blackbox
    

Static Build

  1. Download the C file. Put a copy of the file under the modules/loggers directory under your Apache source build.
  2. In your configuration block, add the following:
    --with-module=loggers:mod_log_report_port.c
    
    It looks like with Apache 2.0.59, you need to use:
    --with-module=loggers:log_report_port
    
  3. Proceed with the Apache build as normal.

Issues

For some reason, the build process wants the module named log_remote_port_module when building a static module. The linker prepends _module (or expects _module) at the end of the module name. I need to do more research on this.

No running bugs have been encountered.

Original test environment was a AMD Turion laptop running Solaris Nevada build 37 against Apache version 2.0.58. Code has also been tested in a RHES AS 3 environment with a custom apache with mod_perl build.

Questions

If you have questions or compile problems, send me an email.