%@ page contentType="text/html; charset=utf-8" %>
<%
// Set CORS HTTP Header Start
response.setHeader("Access-Control-Allow-Credentials", "true");
response.setHeader("Access-Control-Allow-Headers", "X-Requested-With");
// a String containing the value of the requested header, or null if the request does not have a header of that name
String origin = request.getHeader("Origin");
System.out.println("request origin = " + origin);
if (origin == null) { response.setHeader("Access-Control-Allow-Origin", "*"); }
else { response.setHeader("Access-Control-Allow-Origin", origin); }
// Set CORS HTTP Header End
//x-forwarded-for는 클라이언트가 프록시 (Proxy) 뒤에 있을 경우 실제 IP 주소를 알기 위한 용도로 사용할 수 있다.
String ip = request.getHeader("X-FORWARDED-FOR");
System.out.println("X-FORWARDED-FOR = [" + ip + "]");
if(ip == null || ip.length() == 0) {
ip = request.getHeader("Proxy-Client-IP");
System.out.println("Proxy-Client-IP = [" + ip + "]");
}
if(ip == null || ip.length() == 0) {
ip = request.getHeader("WL-Proxy-Client-IP"); // 웹로직
System.out.println("WL-Proxy-Client-IP = [" + ip + "]");
}
if (ip == null || ip.length() == 0) {
ip = request.getRemoteAddr() ;
System.out.println("getRemoteAddr = [" + ip + "]");
}
out.println("{");
out.println("\"result\" : \"" + "1" + "\",");
out.println("\"err_code\" : \"" + "" + "\",");
out.println("\"err_msg\" : \"" + "" + "\",");
out.println("\"ip_addr\" : \"" + ip + "\"");
out.println("}");
%>