
이 문제를 해결하기 위해서는 `$http_x_forwarded_for` 변수를 분리하여 IP 주소 목록으로 변환해야 합니다. 이를 위해 `split` 함수를 사용할 수 있습니다.
로그 포맷팅 옵션을 다음과 같이 수정하면 됩니다.
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "${http_x_forwarded_for#"}" '
'split($http_x_forwarded_for, ",")'';
이 옵션을 사용하면 `$http_x_forwarded_for` 변수의 IP 주소 목록을 분리하여 로그에 출력됩니다. 예를 들어, 다음과 같은 로그가 출력됩니다.
192.168.1.100 - - [2023-03-28 14:30:00] "GET / HTTP/1.1" 200 1234 "http://example.com" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.3" "192.168.1.100, 192.168.1.200"
192.168.1.100
192.168.1.200
이러한 로그 포맷팅 옵션을 사용하면 `$http_x_forwarded_for` 변수의 IP 주소 목록을 분리하여 로그에 출력할 수 있습니다.
2025-03-28 10:16