Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mercure.error.log : Client IP wrong #114

Closed
Pyrrah opened this issue Jul 3, 2019 · 8 comments · Fixed by #120
Closed

mercure.error.log : Client IP wrong #114

Pyrrah opened this issue Jul 3, 2019 · 8 comments · Fixed by #120

Comments

@Pyrrah
Copy link
Contributor

Pyrrah commented Jul 3, 2019

Hello,

I am using Mercury behind a nginx proxy with the following configuration:
location / {
proxy_pass http://127.0.0.1:xxxx;
proxy_read_timeout 24h;
proxy_http_version 1.1;
proxy_set_header Connection "";
}

Unfortunaly, in the logs file "mercure.error.log", the specified IP address is incorrect: client IP is always 127.0.0.1 :(

I tried to add parameters "proxy_set_header", but no success :
proxy_set_header Host $ host;
proxy_set_header X-Real-IP $ remote_addr;
proxy_set_header X-Forwarded-For $ proxy_add_x_forwarded_for;

Can you fix the problem to have the real IP addresses?
Merci par avance Kévin :)

@dunglas
Copy link
Owner

dunglas commented Jul 3, 2019

Forwarded and X-Forwarded-For headers aren't currently supported. It would be a nice addition.
To do so, I suggest to introduce a new environment variable to trust some headers, and then register Gorilla's ProxyHeaders handler: https://github.com/gorilla/handlers

The configuration can be similar to Symfony's one: https://symfony.com/doc/current/deployment/proxies.html#solution-settrustedproxies

@Pyrrah
Copy link
Contributor Author

Pyrrah commented Jul 8, 2019

Great idea, I'm interested!

@dunglas
Copy link
Owner

dunglas commented Jul 8, 2019

Would you be interested on working on a patch? I can assist you if needed!

@Pyrrah
Copy link
Contributor Author

Pyrrah commented Jul 15, 2019

Honestly, I have never worked with Golang and I have never created a patch. We can always try, with some help, and see :)

@dunglas
Copy link
Owner

dunglas commented Jul 22, 2019

I’m working on it.

@Pyrrah
Copy link
Contributor Author

Pyrrah commented Jul 22, 2019

Thanks for the feedback. Maybe for next time (ça me laissera du temps pour jeter un œil sur Golang)

@dunglas
Copy link
Owner

dunglas commented Jul 23, 2019

@Pyrrah could you try if #120 does the job?

@Pyrrah
Copy link
Contributor Author

Pyrrah commented Jul 23, 2019

It's ok for me. I have good datas with IPv4 and IPv6 in the logs.

I pushed a pull request to update the README with good nginx parameters to use argument USE_FORWARDED_HEADERS=1.

Thank you Kevin for the work !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants