Obtain client IP in docker in azure container

Viewed 770

Is there anyone who can help me to obtain user client IP from docker container that runs on Azure container instance ?

My code gets only local IP of something , i guess it is revers proxy. So ip is 10.240.255.106; Is headers I also have host IP (Public container IP) but nothing more. Headers

{"Cache-Control":["max-age=0"],"Connection":["keep-alive"],"Accept":["text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8"],"Accept-Encoding":["gzip, deflate"],"Accept-Language":["en-US,en;q=0.9,ru-RU;q=0.8,ru;q=0.7"],"Host":["23.99.249.54"],"User-Agent":["Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36"],"Upgrade-Insecure-Requests":["1"],"DNT":["1"]}

Is there a way to get real client IP?

2 Answers

To get the client IP in asp.net core inside the controller action:

var ip = Request.HttpContext.Connection.RemoteIpAddress;
Related