dunglas / mercure

🪽 An open, easy, fast, reliable and battery-efficient solution for real-time communications
https://mercure.rocks
GNU Affero General Public License v3.0
3.91k stars 291 forks source link

Use of x-forwarder-for and metadata in "New subscriber" logs #546

Open si14 opened 3 years ago

si14 commented 3 years ago

First of all, thanks for this awesome piece of software!

We've deployed the latest Mercure and it works great. However, there are two tiny ops snags in its logging as you can see on the screenshot:

Screenshot 2021-08-04 at 20 14 57

Firstly, it uses IP of our LB, not the one from X-Forwarder-For. There is a very old issue about this that eventually got fixed https://github.com/dunglas/mercure/issues/114 , but I guess the fix was lost during the big rewrite.

Secondly, do you think it's possible to log JWT payload if it's present? According to the spec, we can grab it by subscribing to the subscription topic, but that would require a separate service just to log those payloads. "New subscriber" log entries are already there, so if payload can be logged as well it would be perfect.

Hopefully I don't miss anything from the docs that makes those points moot.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

si14 commented 2 years ago

I think the bot was too eager to close it :(

dunglas commented 2 years ago

Hi @si14,

Regarding X-Forwarded-For, I think that this should be handled at Caddy's level. It's probably already to do this kind of rewrite (but I'm not sure if it's a good idea).

Regarding logging JWT payload, indeed it's a good idea, especially now that Caddy will allow to easily filter and redact log fields. Do you want to try to open a PR?

SherinBloemendaal commented 1 year ago

How should i use it in Caddy? I've read something about the reverse_proxy directive that has a trusted_proxies option but i can't figure out how to use that in the mercure directive. What should i use for Caddy?