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

HttpContext.Connection.RemotePort is not the remote client's port #855

Closed
1 task
YDKK opened this issue Apr 21, 2021 · 2 comments
Closed
1 task

HttpContext.Connection.RemotePort is not the remote client's port #855

YDKK opened this issue Apr 21, 2021 · 2 comments
Labels

Comments

@YDKK
Copy link

YDKK commented Apr 21, 2021

Description

In #89, the support of obtaining HttpContext.Connection.RemotePort value from the APIGatewayProxyRequest's Headers["X-Forwarded-Port"] is implemented.
However, this value is not a remote client's port, but the API Gateway's listen port.

Reproduction Steps

  1. In Visual Studio, create a new Project using the AWS Serverless Application Project Template.
  2. Choose ASP.NET Core 5 (Container I... blueprint.
  3. Create a new controller with the code like below.
[HttpGet]
public IActionResult Test()
{
    var c = Request.HttpContext.Connection;
    Logger.LogInformation($"Source IP address: {c.RemoteIpAddress}, port: {c.RemotePort}");
    return Ok();
}
  1. Right click on the Project and Publish to AWS Lambda.
  2. Access to the controller over the API Gateway and check the logger output.

Logs

The logs will be like this.

[Information] TestApi.Controllers.TestController: Source IP address: xx.xx.xxx.xxx, port: 443 

The source IP address shows the real remote client's IP address, but the port shows the API Gateway's listen port.

Environment

  • Build Version: 5.3.0
  • OS Info: Windows 10
  • Build Environment: Visual Studio
  • Targeted .NET Platform: .NET 5.0

Resolution

  • 👋 I can/would-like-to implement a fix for this problem myself

This is a 🐛 bug-report

@YDKK YDKK added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Apr 21, 2021
@ashishdhingra ashishdhingra added module/aspnetcore-support B needs-reproduction This issue needs reproduction. and removed needs-triage This issue or PR still needs to be triaged. labels Apr 21, 2021
@ashishdhingra
Copy link
Contributor

Needs investigation.

@github-actions
Copy link
Contributor

We have noticed this issue has not received attention in 1 year. We will close this issue for now. If you think this is in error, please feel free to comment and reopen the issue.

@github-actions github-actions bot added closing-soon This issue will automatically close in 4 days unless further comments are made. closed-for-staleness and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels Apr 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants