Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

We have apache webserver as "entry" for incoming traffic it then delegates to tomcats with mod_jk.

We want to log the HTTP digest username, sample header:

Authorization: Digest username="Mufasa",
                     realm="testrealm@host.com",
                     nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093",
                     ...

Unfortunately using the '%u' doesn't work as described. My guess is as we authenticate on tomcat side (apache delegates calls to tomcat with mod_jk) the own logging facility of apache doesn't know how to access the digest-username (because own auth module is bypassed).

To workaround this: Is there a custom log-format expression with regex matching for, e.g. telling to extract username="(.*?)" from 'Authorization' header and push to logs?

share|improve this question

1 Answer 1

up vote 1 down vote accepted
SetEnvIf Authorization username="([^"]+)" digest_username=$1
LogFormat "%h %l %{digest_username}e %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" combined_with_user
CustomLog /path/to/log combined_with_user

Haven't tested, so not sure if Apache is going to choke on the quotes in the SetEnvIf (they may need escaped) - but this should be pretty close.

share|improve this answer
    
thanks, this one looks promising. will accept answer when I tried out on our servers. –  manuel aldana Oct 9 '11 at 20:44
    
works like a charm, thanks again! –  manuel aldana Oct 11 '11 at 6:56

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.