nginx + tomcat - tomcat 로그, 접속 아이피 남기기


nignx 설정

location ~ \.jsp$ {

proxy_pass              http://localhost:8080;

proxy_set_header        X-Real-IP $remote_addr;

proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_set_header        Host $http_host;

}



tomcat server.xml 에서

<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="localhost_access_log." suffix=".txt"
               pattern="%{X-Forwarded-For}i %h %l %u %t &quot;%r&quot; %s %b" resolveHosts="false"/>



jsp 에서 

request.getHeader("X-Forwarded-For");



http://serverfault.com/questions/514551/make-tomcat-use-x-real-ip


<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="access_log." suffix=".txt"
               pattern="Remote User[ %{X-Forwarded-For}i %l %u %t ] Request[ &quot;%r&quot; ] 
               Status Code[ %s ] Bytes[ %b ] Referer[ &quot;%{Referer}i&quot; ] 
               Agent[ &quot;%{User-agent}i&quot; ] " />


Posted by [czar]
,