nginx에서 XFF(X-Forwarded-For)를 설정하는 방법
nginx는 X-Forwarded-For 헤더를 사용하여 클라이언트의 실제 IP 주소를 결정할 수 있습니다.
nginx 구성 파일 편집
- set_real_ip_from <可信IP地址>;
- real_ip_header X-Forwarded-For;
sudo vim /etc/nginx/nginx.conf
http {
...
set_real_ip_from 0.0.0.0/0;
real_ip_header X-Forwarded-For;
...
}
nginx 구성(nginx.conf) 파일 구문 확인
nginx -t
$ nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
nginx 서비스를 다시 시작하십시오.
systemctl restart nginx