我正在构建一个托管在AWS (Elastic Beanstalk服务)上的API。
我读了很多关于这个问题的东西,但我不明白为什么它在我的情况下不起作用。
我在我的负载均衡器上设置了HTTPs监听器
这是我的日志
{
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'
}
这是/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;
}
我的应用程序在NodeJS上运行
因此,如果您已经遇到此问题,将会很有帮助:)
谢谢
发布于 2021-06-01 17:22:12
好了,我终于明白为什么我没有客户端IP了。
我在SSL/TCP模式下使用ELB,在这种情况下,没有提供客户端ip。我切换到ALB,一切都运行得很好。(甚至Websockets)
https://stackoverflow.com/questions/67776497
复制相似问题