Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have a requirement related to the apache access log file format:
When a user access my local site, http authentication will be displayed:
Code:
username: saagar
password: 123
I wish to have the LogFormat in the configuration file in such a way that the username and password (saagar/123 in this case) will be logged in the /var/log/apache2/mysite_access_log file. I used the %u parameter as follows:
Code:
LogFormat "%h %u \"%r\" %>s %b" common
CustomLog /var/log/apache2/mydreamhome_access.log common
and it works, similarly I wish the password too to be displayed in the access_log file.
Why don't you use the combined Logformat, so apache logs more things like referer and browser user-agent
Anyway, you can log the "Authorization" header. In this case you'll get a "Basic usernameassword" in the logs, where Basic is the authentication method and the u/p pair is encoded in base64
There is an "Authorization" header containing credentials, returned when a user authenticates himself using apache authentication.
So, from apache documentation about LogFormat:
Quote:
%{Foobar}i The contents of Foobar: header line(s) in the request sent to the server. Changes made by other modules (e.g. mod_headers) affect this.
I used the following way as you guided plus the cookie-related entry (as suggested by a different site) but I get a "-" correspoding to it.
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Cookie}i\" \"%{Referer}i\" \"%{User-Agent}i\"" combined
CustomLog /var/log/apache2/mydreamhome_access.log combined
I cannot see where the Authorization header is. You need to add "%{Authorization}i\" in the LogFormat above
Glad to see it worked, but once again I want to warn you. Base64 encoded stuff can be very easily decoded. It's not hashed like a usual password, that is hard to crack.
So having a username/password in the logfile could be a potential risk for your server.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.