etherpad-lite icon indicating copy to clipboard operation
etherpad-lite copied to clipboard

Logging Client IPs to a separate Log file

Open disy-mk opened this issue 13 years ago • 20 comments

I am using EPL behind nginx proxy. I was a bit confused about the log entries (log level 'INFO').

e.g.

[2013-01-24 14:29:47.196] [INFO] message - to X61TZLoSCIJjCN6_efal: {"type":"COLLABROOM","data":{"type":"USER_LEAVE","userInfo":{"ip":"127.0.0.1","colorId":"#754d80","userAgent":"Anonymous","userId":"a.8mKmFQrR9UwHGThM"}}}

OK, i thought, it's 127.0.0.1 because of of nginx locally accesses the pads. But trying to access the pads externally without SSL revealed, that this IP stays the same. I am not sure, if that info even is supposed to state the IP of the visitor. IP gets passed by nginx as follows:

    proxy_set_header    Host    $host;
    proxy_set_header   X-Real-IP        $remote_addr;

Actually, with nginx log, I have a possibility to kinda sort out which IP belongs to which pad access; but I would prefer to have that info in EPL log (or did I miss some config option?).

If that feature does not exist yet, it maybe would be nice to have the possibility to add this (maybe to a separate) access log file. (because at a certain level of productivity environment keeping the log level to 'INFO' would be overkill... and an IP not really is something to WARN about...)

disy-mk avatar Jan 24 '13 14:01 disy-mk

put your external IP in your settings.json

JohnMcLear avatar Jan 24 '13 15:01 JohnMcLear

@JohnMcLear I guess you did not get what I was trying to explain :-)

I guess you are referring to the binding-ip. But if you use EPL not only behind an app, but also publicly, it would be nice to have some ip-logging - although I am a friend of pirate pads ;-)

I am talking about the IP addresses of people creating/accessing a pad. Like an apache access log. Maybe a separate log file (additionally to /var/log/etherpad-lite/etherpad-lite.log), e.g. etherpad-lite-access.log, containing creating/accessing pads entries like in the current EPL log file, but instead of all file accesses only creation/accessing/modifying (/w revision info) infos. e.g. instead of

[2013-01-24 16:11:06.313] [INFO] http - 200, GET /p/logip
[2013-01-24 16:11:06.414] [INFO] http - 200, GET /static/js/html10n.js
[2013-01-24 16:11:06.415] [INFO] http - 200, GET /static/custom/pad.css
[2013-01-24 16:11:06.415] [INFO] http - 200, GET /static/css/pad.css
[2013-01-24 16:11:06.420] [INFO] http - 200, GET /static/js/require-kernel.js
[2013-01-24 16:11:06.421] [INFO] http - 200, GET /static/js/l10n.js
[2013-01-24 16:11:06.472] [INFO] http - 200, GET /javascripts/lib/ep_etherpad-lite/static/js/pad.js?callback=require.define
[2013-01-24 16:11:06.501] [INFO] http - 200, GET /javascripts/lib/ep_etherpad-lite/static/js/ace2_common.js?callback=require.define
[...]

something like

[2013-01-24 16:11:06.313 165.122.34.6] [create pad]  /p/logip
[2013-01-24 16:11:08.415 182.16.2.122] [access pad]  /p/logip
[2013-01-24 16:11:12.313 165.122.34.6] [modify pad]  /p/logip (rev 1)
[2013-01-24 16:11:14.313 165.16.2.122] [modify pad]  /p/logip (rev 2)
[...]

disy-mk avatar Jan 24 '13 15:01 disy-mk

yes i did. do you have your external IP in your settings.json?

JohnMcLear avatar Jan 24 '13 15:01 JohnMcLear

@JohnMcLear which setting in settings.json do you refer to?

disy-mk avatar Jan 24 '13 16:01 disy-mk

ip

JohnMcLear avatar Jan 24 '13 16:01 JohnMcLear

it was set to 127.0.0.1, becuase I was using nginx as a reverse proxy to be able to use SSL. Just found out (while comparing setting.json.template to my own settings.json which is ages some releases...) that noed.js now natively supports SSL. So I disabled nginx and configured EPL to use SSL via node.js. There I set the IP to 0.0.0.0, in order to make the pads accessible publicly.

disy-mk avatar Jan 24 '13 16:01 disy-mk

The user-IP info I referred to

[2013-01-24 14:29:47.196] [INFO] message - to X61TZLoSCIJjCN6_efal: {"type":"COLLABROOM","data":{"type":"USER_LEAVE","userInfo":{"ip":"127.0.0.1","colorId":"#754d80","userAgent":"Anonymous","userId":"a.8mKmFQrR9UwHGThM"}}}

seems to be even hardcoded:

./src/node/handler/PadMessageHandler.js:121:            "ip": "127.0.0.1",
./src/node/handler/PadMessageHandler.js:1092:           "ip": "127.0.0.1",
./src/node/handler/PadMessageHandler.js:1161:           "ip": "127.0.0.1",

as well as the userAgent

So if I understand everything correctly I should split my concern into a bug and a separate feature request (regarding the possibility to separately log pad accesses and modifications).

disy-mk avatar Jan 24 '13 16:01 disy-mk

Well that's a problem.. We need to fix that.. I have no idea how that happened.

JohnMcLear avatar Jan 24 '13 16:01 JohnMcLear

:)

marcelklehr avatar Jan 24 '13 16:01 marcelklehr

https://github.com/ether/etherpad-lite/blob/115f7d6b5124a75f32654eb45c8e0edd65863f4e/node/PadMessageHandler.js

JohnMcLear avatar Jan 24 '13 16:01 JohnMcLear

    "clientIp": (client.request && client.request.connection) ? client.request.connection.remoteAddress : "127.0.0.1",

JohnMcLear avatar Jan 24 '13 16:01 JohnMcLear

I just realized you are looking at a message broadcasted to all clients. That is the correct behavior. We don't want to publish the client IP to other clients. That would be a huge security issue. Do you not have other messages in your log that show activity (server side)?

JohnMcLear avatar Jan 24 '13 16:01 JohnMcLear

@JohnMcLear OK, as I seemed to be wrong about my issue, the current behavior looks OK.

Then now only my feature request is left. The thing is: I had (using nginx as reverse proxy to obtain SSL). But having no need for nginx at that point any more, there is no "log" layer left between EPL and the clients. Therefore my request for being able to log the clients IPs is of even greater importance now. IMHO the nicest way to handle that cleanly would be an option to enable logging the infos I proposed into a separate file.

disy-mk avatar Jan 24 '13 17:01 disy-mk

@marcelklehr didn't you add something about extending logging just last week?

JohnMcLear avatar Jan 24 '13 17:01 JohnMcLear

The log4j feature?

disy-mk avatar Jan 24 '13 17:01 disy-mk

Yea, but that can only log what is console.logged :)

There are hooks for pad events like edit/create/delet, though...

marcelklehr avatar Jan 24 '13 17:01 marcelklehr

Well, as the fundamentals already exist... one of you is doing me that favor and adds that feature? :)

disy-mk avatar Jan 24 '13 17:01 disy-mk

no one else interested in that?

disy-mk avatar Feb 10 '13 13:02 disy-mk

Fixed in #1489

marcelklehr avatar Feb 10 '13 15:02 marcelklehr

me gusta... :)

thx

disy-mk avatar Feb 10 '13 15:02 disy-mk