在SSL Nginx代理上获取http_x_forwarded_for

时间:2018-06-29 19:29:23

标签: amazon-web-services nginx elastic-beanstalk

我有一个使用以下侦听器运行nginx的弹性beantalk应用程序:

{
    "Listener": {
        "InstancePort": 80, 
        "SSLCertificateId": "xxxx", 
        "LoadBalancerPort": 443, 
        "Protocol": "SSL", 
        "InstanceProtocol": "TCP"
    }, 
    "PolicyNames": [
        "ELBSecurityPolicy-2016-08"
    ]
}, 
{
    "Listener": {
        "InstancePort": 80, 
        "LoadBalancerPort": 80, 
        "Protocol": "HTTP", 
        "InstanceProtocol": "HTTP"
    }, 
    "PolicyNames": []
}

当我通过简单的http请求时,我获得了带有客户端ip的$http_x_forwarded_for,一切都很好。但是,如果我通过https(自从我们执行https以来一直都是这样),则$http_x_forwarded_for变量为空

我检查了this answer,因此我遵循了官方文档 here,但随后我开始从Nginx收到错误的请求错误

这是来自nginx访问日志

172.31.15.163 - - [29/Jun/2018:18:04:22 +0000] "PROXY TCP4 172.31.15.163 172.31.15.163 57848 80" 400 173 "-" "-"

日志格式:

log_format  default '$remote_addr - $remote_user [$time_local] "$request" '
                    '$status $body_bytes_sent "$http_referer" '
                    '"$http_user_agent" "$http_x_forwarded_for"';

0 个答案:

没有答案