dotnet / dotnet/MQTTnet

X-Forward-For header is not rewriting endpoint address when ASP.NET core 3.1 is behind a reverse proxy

Open
#1,000 5 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
C#
Stars
5.1k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

### Describe the bug
If you are using .net core 3.1 and ASP NET Core, the endpoint is never updated to match the actual HttpContext RemoteIpAddress due to the implementation introduced in: c10145f743694474489fc254a70ef8a0b73eb2b9.

In c10145f743694474489fc254a70ef8a0b73eb2b9 the ConnectionContext is added to get the endpoint string but it looks likes that no middleware(HttpOverrides over HttpContext should) is rewriting the RemoteEndpoint field.

Perhaps c10145f743694474489fc254a70ef8a0b73eb2b9 is not needed anymore, I have checked without those changes and the RemoteIpAddress is present (IPV4 over IPV6 format). Am I missing something?

### Which project is your bug related to?
-MQTTnet.AspNetCore

### To Reproduce
Steps to reproduce the behaviour:
1. Run MQTTNET over Websockets
2. Check the Endpoint string in the MQTTnet.Server.MqttConnectionValidatorContext
3. See proxy IP instead of the X-Forwarded-For IP.

### Expected behaviour
The remote endpoint should expose the X-Forwarded-For IP Header address.

Best regards

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.