我有以下内容可以打印出所有请求标头。它没有打印出X-Forwarded-For
标题。该文档指出,Elastic Beanstalk确实转发了客户端的真实 IP。
https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/x-forwarded-headers.html
private method(@RequestHeader final HttpHeaders headers) {
StringBuffer sb = new StringBuffer();
headers.forEach((h, v) -> {
sb.append(h);
sb.append(v);
System.out.println(h+": "+v);
});
当我查看环境的 AWS 日志时,我看到x-forwarded-proto
andx-forwarded-port
但没有x-forwarded-for
。为什么?
connection: [upgrade]
host: [dev.example.com]
x-real-ip: [172.99.99.999]
x-forwarded-proto: [https]
accept: [text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3]
accept-encoding: [gzip, deflate, br]
accept-language: [en-US,en;q=0.9]
cache-control: [no-cache]
cookie: [_ga=GA1.2.9999999.999999999; JSESSIONID=99AAA9999A999A99999AAAAA99999AAA999; AWSELB=99999AAA9999AAAA99999AAAA]
pragma: [no-cache]
sec-fetch-mode: [navigate]
sec-fetch-site: [none]
sec-fetch-user: [?1]
upgrade-insecure-requests: [1]
user-agent: [Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Mobile Safari/537.36]
x-forwarded-port: [443]