Showing posts with label Apache. Show all posts
Showing posts with label Apache. Show all posts

Friday, September 2, 2011

Apache syslogging on FreeBSD

If you need to use Syslog to send Apache log output there are plenty of examples already on the Internet. The first hit on google was the O'Reilly Sysadmin blog, which is very useful. However, the page is a bit old and the perl script they provide for Syslogging access logs is in need of updating. My modified version is below. To summarize the process..

  1. Put the following script in /usr/local/bin/apache_syslog.


    #!/usr/bin/perl

    # $Id$
    #
    # A wrapper script that logs apache access via syslog. Copied from an example
    # at http://oreilly.com/pub/a/sysadmin/2006/10/12/httpd-syslog.html
    # Script requires sysutils/p5-Sys-Syslog from FreeBSD ports.
    #

    use Sys::Syslog qw( :DEFAULT setlogsock );

    # Excluded, per the rules of Sys:Syslog
    # http://search.cpan.org/~saper/Sys-Syslog-0.29/Syslog.pm#THE_RULES_OF_SYS::SYSLOG
    #setlogsock('unix');
    openlog('httpd', "cons, pid", 'local2');

    while ($log = ) {
    syslog('notice', $log);
    }

    closelog;

  2. Install sysutils/p5-Sys-Syslog from ports (FreeBSD).
  3. In your Apache config replace your ErrorLog directive with "ErrorLog syslog:local1".
  4. Replace your CustomLog directive (for access logs) with "CustomLog |/usr/local/bin/apache_syslog combined".
  5. Edit /etc/syslog.conf, adding the following lines
    !httpd
    local1.* /var/log/httpd-error.log
    local2.* /var/log/httpd-access.log
    !*
  6. Create the log files with "touch /var/log/httpd-error.log /var/log/httpd-access.log".
  7. Edit /etc/newsyslog.conf, adding the following lines
    /var/log/httpd-error.log 640 14 * @T00 J
    /var/log/httpd-access.log 640 14 * @T00 J
  8. (Re)start syslogd and apache.
  9. Profit.


Wednesday, April 6, 2011

Apache startup problems

After spending the better part of a day trying to track this problem down, I figured I'd be nice and share the fix, since google wasn't helpful. I was trying to fix a previously working apache installation and found that I was unable to authenticate using LDAP. With the apache logging set to debug, I received the following messages.

At apache startup:
[Wed Apr 06 08:56:30 2011] [debug] mod_authnz_ldap.c(1010): [2999] auth_ldap url parse: `ldap://ldap.blissfulidiot.com/ou=people,dc=blissfulidiot,dc=com?uid?sub?(clxEnabled=TRUE)', Host: ldap.blissfulidiot.com, Port: 389, DN: ou=people,dc=blissfulidiot,dc=com, attrib: uid, scope: subtree, filter: (clxEnabled=TRUE), connection mode: not using SSL

At authentication attempt:
[Wed Apr 06 08:57:58 2011] [debug] mod_authnz_ldap.c(403): [client 10.0.3.6] [5604] auth_ldap authenticate: using URL ldap://ldap.blissfulidiot.com/ou=people,dc=blissfulidiot,dc=com?uid?sub?(clxEnabled=TRUE)
[Wed Apr 06 08:57:58 2011] [info] [client 10.0.3.6] [5604] auth_ldap authenticate: user tom authentication failed; URI / [LDAP: ldap initialization failed][Unknown (private extension) error]

The solution for me on FreeBSD, rebuild the apr port.