把用户名在Apache的访问日志用PHP和不HTTP认证 [英] Put username in apache access_log with PHP and without HTTP auth

查看:192
本文介绍了把用户名在Apache的访问日志用PHP和不HTTP认证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Apache日志配置,可以指定该HTTP认证的用户名应记录。大多数PHP脚本有自己的,基于Cookie的身份验证。是否有可能在PHP提供Apache的一个HTTP认证的用户名进行日志记录,即使验证基于cookie的?如果是的话,怎么会在code是什么样子?如果不是,有什么办法?

In the Apache log configuration it is possible to specify that the HTTP auth user name should be logged. Most PHP scripts have their own, cookie-based authentication. Is it possible in PHP to provide Apache with a HTTP auth username for logging purposes, even if the authentication is cookie-based? If yes, how would the code look like? If not, what are alternatives?

推荐答案

阿帕奇通过模块之间的数据中的注释的。如果你运行PHP作为Apache模块,你可以使用 apache_note() 得到并设置笔记。然后,您可以%{note_name} n的日志格式字符串写这篇的访问日志。这不会泄漏的任何数据返回给客户端。

Apache passes data between modules in notes. If you run PHP as an Apache module, you can use apache_note() to get and set notes. You can then include the %{note_name}n log format string to write this to the access log. This will not "leak" any data back to the client.

在PHP:

apache_note( 'username', $username );

在你的服务器配置:

LogFormat "%h %l %{username}n %t \"%r\" %>s %b" common_with_php_username
CustomLog logs/access_log common_with_php_username

这篇关于把用户名在Apache的访问日志用PHP和不HTTP认证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆