5

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?

Charles Xu
  • 29,862
  • 2
  • 22
  • 39
grinay
  • 709
  • 1
  • 6
  • 21

2 Answers2

4

No, ACI doesn't preserve the client IP. You can create a feature request in the user voice. https://feedback.azure.com/forums/602224-azure-container-instances?filter=top&page=1

Robbie Zhang
  • 111
  • 2
0

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

var ip = Request.HttpContext.Connection.RemoteIpAddress;
Aman B
  • 2,276
  • 1
  • 18
  • 26
  • Yes. That is right. But unfortunately inside of azure container(docker) you will get ip of container. – grinay Oct 26 '18 at 10:40
  • Can you pass param `--network host` when you run the container so its runs on the host network and not on NAT? – Aman B Oct 26 '18 at 10:53
  • Unfortunately no.They don't allow specify network setting. Or I don't know how to do this. – grinay Oct 26 '18 at 12:06