httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Knoblauch <kn...@knobisoft.de>
Subject Re: [users@httpd] How to print request headers before and after processing
Date Fri, 23 Mar 2018 09:38:10 GMT
Hi Rainer,

 thanks for the enlightenment :-) I was not aware, that the RewriteRule
check is done before actually evaluating the RewriteCond(s). So, out of
curiosity I gave it a try. As I only need to look for the GET request on
the login-page, this works fine for me:

RewriteCond "%{REQUEST_METHOD}" "GET"
RewriteRule ^/xxx/facelets/logon.xhtml$ - [E=login_jsid:%{HTTP_COOKIE}]


 Surprisingly, here I can use a variable in the assignment to "login_jsid"
:-) Otherwise, this would have worked as well:

RewriteCond "%{REQUEST_METHOD}" "GET"
RewriteCond "%{HTTP_COOKIE}" "(.*)"
RewriteRule ^/xxx/facelets/logon.xhtml$ - [E=login_jsid:%1]

Clearly, the logging is now much better than with the "forensic" stuff. Now
to the main task :-)

Cheers
Martin




On Thu, Mar 22, 2018 at 8:28 PM, Rainer Jung <rainer.jung@kippdata.de>
wrote:

> Am 22.03.2018 um 18:56 schrieb Martin Knoblauch:
>
>> Hi Rainer,
>>
>>   unfortunately mod_log_debug seems to work only on directory scope, not
>> on virtual host.
>>
>
> But note, that <Location> is directory scope, for instance
>
> <Location /cb2/facelets/logon.xhtml>
>    ...
> </Location>
>
> And I considered the mod_rewrite thingy, but feared it to be to expensive.
>>
> >
>
>>   In the meantime I found "mod_log_forensic". Ugly, I do not know the
>> cost, but it works for my purpose.
>>
>
> I think mod_rewrite is not that expensive.
>
> When a RewriteCond and a RewriteRuke is combined, it will first check the
> left side of the RewriteRule against your URL. If it doesnt match, the
> RewriteCond and the flags are not evaluated. So it is important to not have
> a complex pattern in RewriteRule. In your case it is not complex.
>
> Then next te RewriteCond is checked. In your case picking one header and
> matching with ".*" which is also not very expensive (not backtracking).
>
> And then finally the env var setting. Performancewise this will be very
> close to the SetEnvIf variant.
>
> Regards,
>
> Rainer
>
> Thanks
>> Martin
>>
>> On Thu, Mar 22, 2018 at 6:16 PM, Rainer Jung <rainer.jung@kippdata.de
>> <mailto:rainer.jung@kippdata.de>> wrote:
>>
>>     Am 22.03.2018 um 18:08 schrieb Eric Covener:
>>
>>         On Thu, Mar 22, 2018 at 1:03 PM, Martin Knoblauch
>>         <knobi@knobisoft.de <mailto:knobi@knobisoft.de>> wrote:
>>
>>             Hi Eric,
>>
>>                thanks, but does not work.
>>
>>             login_jsid=Cookie  prints "Cookie"
>>             login_jsid=%{Cookie} prints "%{Cookie}"
>>
>>             Apparently the right sides of the assignment are just taken
>>             as literals
>>             without evaluating them as variables.
>>
>>
>>         Arg, sorry, It is only for the first arg.
>>
>>             Had a brief look at mod_log_debug, but do not see how it
>>             helps me in this
>>             case.
>>
>>
>>         You could log expressions before/after the  your edits.
>>
>>
>>     ... by choosing different hooks.
>>
>>     If that does not work, you could also try to copy the header to an
>>     env var using mod_rewrite. Something like
>>
>>     RewriteCond "%{HTTP_COOKIE}" "(.*)"
>>     RewriteRule ^/cb2/facelets/logon.xhtml$ - [E=login_jsid:%1]
>>
>>     But you need to test. Not sure in what order the mod_headers
>>     replacement and the mod_rewrite rule handling run. I vaguely
>>     remember having used a trick like this.
>>
>>     Including your marker login_get should work like this:
>>
>>     RewriteCond "%{HTTP_COOKIE}" "(.*)"
>>     RewriteRule ^/cb2/facelets/logon.xhtml$ -
>> [E=login_jsid:%1,E=login_get]
>>
>>     Regards,
>>
>>     Rainer
>>
>>
>>
>>     ---------------------------------------------------------------------
>>     To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>>     <mailto:users-unsubscribe@httpd.apache.org>
>>     For additional commands, e-mail: users-help@httpd.apache.org
>>     <mailto:users-help@httpd.apache.org>
>>
>>
>>
>>
>> --
>> ------------------------------------------------------
>> Martin Knoblauch
>> email: k n o b i AT knobisoft DOT de
>> www: http://www.knobisoft.de
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>


-- 
------------------------------------------------------
Martin Knoblauch
email: k n o b i AT knobisoft DOT de
www: http://www.knobisoft.de

Mime
View raw message