프로그래밍/Spring Framework

Spring Boot - nginx + tomcat 연동시 리얼아이피 설정

모지사바하 2016. 1. 7. 14:57

1.application.properties 또는 yml 에

server.tomcat.protocol-header=x-forwarded-proto
server.tomcat.protocol-header-https-value=https
server.use-forward-headers=true
server.tomcat.remote-ip-header=x-forwarded-for


를 추가하여준다.



2. nginx.conf 에


location / {

            proxy_pass http://argos-api;

            proxy_set_header X-Real-IP $remote_addr;

            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

            proxy_set_header Host $host;

        }



를 추가해준다.


3. 소스상에서 request.getRemteAddr() 을 호출하면 real IP 확인 가능하다.