在server中添加3个字段,然后再程序中通过获取Header中的X-Forwarded-For取出真实客户端IP
server {
listen 8090;
server_name localhost;
root html/h5;
location /api/registerAfter/ {
proxy_pass http://127.0.0.1:2022/;
}
location /callback/ {
proxy_pass http://127.0.0.1:5022/;
}
location / {
try_files $uri $uri/ /;
index index.html index.htm;
}
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}