0
votes

I'm building an API hosting on AWS (Elastic Beanstalk service).

I read a lot of things on this issue, but I can't figure out why it's not working in my case.

I've set up HTTPs listener on my load balancer enter image description here

And here is my logs

 {
May 31 15:00:24 ip-172-31-45-140 web: connection: 'upgrade',
May 31 15:00:24 ip-172-31-45-140 web: host: 'api.website.app',
May 31 15:00:24 ip-172-31-45-140 web: 'x-real-ip': '172.xx.xx.xxx',
May 31 15:00:24 ip-172-31-45-140 web: 'x-forwarded-for': '172.xx.xx.xxx',
May 31 15:00:24 ip-172-31-45-140 web: 'content-length': '17',
May 31 15:00:24 ip-172-31-45-140 web: 'content-type': 'application/x-www-form-urlencoded',
May 31 15:00:24 ip-172-31-45-140 web: 'user-agent': 'App/19 CFNetwork/1237 Darwin/20.4.0',
May 31 15:00:24 ip-172-31-45-140 web: 'if-none-match': 'W/"d8a-WUss32mkaKBHy8bMoUkg04aC7OQ"',
May 31 15:00:24 ip-172-31-45-140 web: accept: 'application/json, text/plain, */*',
May 31 15:00:24 ip-172-31-45-140 web: 'accept-language': 'fr-fr',
May 31 15:00:24 ip-172-31-45-140 web: 'accept-encoding': 'gzip, deflate, br'
}

And here is /etc/nginx/conf.d/00_application.conf

location / {
    proxy_pass          http://127.0.0.1:8080;
    proxy_http_version  1.1;

    proxy_set_header    Connection          $connection_upgrade;
    proxy_set_header    Upgrade             $http_upgrade;
    proxy_set_header    Host                $host;
    proxy_set_header    X-Real-IP           $remote_addr;
    proxy_set_header    X-Forwarded-For     $proxy_add_x_forwarded_for;
}

My app is running on NodeJS

So if you already had this issue, would be helpful :)

Thanks

1

1 Answers

0
votes

Ok I finally figure out why i hadn't client IP.

I was using ELB in SSL/TCP mode, and in this case, client ip is not provided. I switched to ALB and everything is working great. (Even Websockets)