리눅스
Nginx에서 X-Forwarded-For(XFF) 설정하는 방법
변군이글루
2023. 3. 15. 08:41
반응형
Nginx에서 X-Forwarded-For(XFF) 설정하는 방법
Nginx에서 X-Forwarded-For (XFF) 헤더를 설정하는 것은 주로 프록시 서버나 로드 밸런서와 같은 중간 서버를 통해 클라이언트의 IP 주소를 추적하려는 경우에 사용됩니다. XFF 헤더는 클라이언트의 실제 IP 주소를 서버로 전달하기 위해 사용됩니다. X-Forwarded-For 헤더를 사용하여 클라이언트의 실제 IP 주소를 확인할 수 있다.
Nginx 설정 파일 편집
- set_real_ip_from <trusted IP address>;
- 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
728x90
반응형