应该是return 早于 realip模块执行
`
http {
access_log logs/access.log;
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://127.0.0.1:81/;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
server {
listen 81;
server_name localhost;
location / {
set_real_ip_from 127.0.0.1;
real_ip_header X-Forwarded-For;
real_ip_recursive on;
access_by_lua_block {
ngx.say(ngx.var.remote_addr)
return ngx.exit(200)
}
}
}
}
`