Spring boot 로그에 X-Forwarded-For를 통해서 client IP 기록하기
2024. 12. 29. 20:07ㆍJava/Spring Boot
application.yml
server:
port: {port}
tomcat:
use-relative-redirects: true
basedir: .
accesslog:
enabled: true
pattern: '%{yyyy-MM-dd HH:mm:ss}t %s %r %{User-Agent}i %{Referer}i %{X-Forwarded-For}i %b'
X-Forwarded-For를 인식하지 못하는 경우, X-Original-Forwarded-For를 사용
server:
port: {port}
tomcat:
use-relative-redirects: true
basedir: .
accesslog:
enabled: true
pattern: '%{yyyy-MM-dd HH:mm:ss}t %s %r %{User-Agent}i %{Referer}i %{X-Original-Forwarded-For}i %b'
X-Original-Forwarded-For 특징
Original client IP 주소를 보관하기 위해서 사용
Single Proxy
X-Forwarded-For: 223.38.56.152
Multiple Proxies
X-Forwarded-For: 223.38.56.152, 192.168.49.1
Preserving the Original IP
X-Original-Forwarded-For: 223.38.56.152