nginx + tomcat proxy config example
Nginx (/etc/nginx/nginx.conf)
location / {
proxy_pass http://127.0.0.1:8080/;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
$remote_addr, $proxy_add_x_forwarded_for 차이점
1. 리퀘스트에 X-Forwarded-For 헤더가 있는 경우
$proxy_add_x_forwarded_for = 리퀘스트의 X-Forwarded-For 헤더값
2. 나머지
$proxy_add_x_forwarded_for = $remote_addr
Tomcat (/usr/tomcat/conf/server.xml)
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log" suffix=".txt" pattern="%{X-Forwarded-For}i %l %u %t "%r" %s %b" />
location / {
proxy_pass http://127.0.0.1:8080/;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
$remote_addr, $proxy_add_x_forwarded_for 차이점
1. 리퀘스트에 X-Forwarded-For 헤더가 있는 경우
$proxy_add_x_forwarded_for = 리퀘스트의 X-Forwarded-For 헤더값
2. 나머지
$proxy_add_x_forwarded_for = $remote_addr
Tomcat (/usr/tomcat/conf/server.xml)
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log" suffix=".txt" pattern="%{X-Forwarded-For}i %l %u %t "%r" %s %b" />
댓글
댓글 쓰기