nginx真实ip
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
log_format main ' "client_ip":$http_x_forwarded_for $proxy_add_x_forwarded_for $remote_addr [$time_local] "$request" "$http_host"' '"$status" $body_bytes_sent "$http_referer"' '"$http_user_agent" $request_length';
server {
1、日志格式中增加 "client_ip":$http_x_forwarded_for
增加后结果:log_format main ' "client_ip":$http_x_forwarded_for $proxy_add_x_forwarded_for $remote_addr [$time_local] "$request" "$http_host"' '"$status" $body_bytes_sent "$http_referer"' '"$http_user_agent" $request_length';
2、在访问日志增加 main
增加后结果:access_log /data/nginx/logs/ipraction_access_${time}.log main;