본문 바로가기
반응형

개발/Web21

[Web] XFF - Load balancers 혹은 Proxy 환경에서 Client IP 가져오기 기존에는 request.getRemoteAddr(); 를 통해 Client의 IP를 가져왔는데 웹서버나 WAS 앞에 L4와 같은 Load balancers나 Proxy server, caching server등이 있는 경우는 원하는 결과를 얻지 못하는 것을 발견하였다. 이런 제품은 웹서버 혹은 WAS에 HTTP나 AJP 요청을 보낸 후 받은 결과를 가공하여 클라이언트에 재전송하기 때문에 위와 같은 현상이 발생한 것이다. ( 클라이언트 IP -> 로드밸런서, 프록시 장비 -> 웹서버 ) 그래서 등장한 것이 XFF(X-Forwarded-For)이다! XFF 에는 Client와 Proxy IP 가 콤마를 구분자로 들어가게 되어있는데 순서는 아래와 같기 때문에 첫번째 IP를 가져오면 Client의 IP를 획득할.. 2022. 1. 20.
[Spring] @Transactional이 적용되지 않을 경우(롤백이 안되는 이유) 1. Checked Exception일 경우 사실 이 항목에 대한 설명을 위해 어제 java의 error와 exception에 대해 포스팅을 했다. Checked Exception이 뭔지 모른다면 먼저 아래 포스팅을 보고 오는 것을 추천! [Java] Error, Checked Exception, Unchecked Exception 비교 자바에서는 예외를 크게 Error와 Exception으로 구분하고, Exception은 RuntimeException 상속 여부에 따라 Checked Exception, Unchecked Exception으로 구분된다. Error 시스템에 비정상적인 상황이 발생한 경.. ynzu-dev.tistory.com Checked Exception는 예외상황 발생시 롤백처리를 하.. 2022. 1. 13.
[Web] redirect시 데이터 전달하는 방법 - RedirectAttributes 결론 : RedirectAttributes 클래스를 사용하면 된다! @Controller class TestController { @PostMapping("/buy") public String buy(@ModelAttribute("testForm") TestVo vo , HttpServletRequest request , RedirectAttributes redirectAttributes){ // 결제 처리 로직 //첫번째 방법 redirectAttributes.addAttribute("param", param); //두번째 방법 redirectAttributes.addFlashAttribute("param", param); return "redirect:/buy-result"; } } addAttrib.. 2022. 1. 7.
[Web] PRG 패턴 (Post - Redirect - Get) PRG 패턴이란? Post -> Redirect -> Get 패턴으로 만들어지는 것을 말하며, 권장되는 디자인 패턴 중 하나다. PRG 패턴의 필요성 예를 들어 상품 판매 서비스를 운영하고 있다고 하자. 주문 페이지를 호출하고, Post 방식으로 결제를 처리할 경우 결제 완료 페이지에서 실수 혹은 의도적으로 새로고침을 하게 되면 서버에 전송했던 데이터를 다시 전송하게 되어 중복 결제 처리가 될 수 있다. 자세한 프로세스는 아래 포스팅을 참고하자 [WEB] PRG패턴 PRG(Post-Redicet-Get)패턴은 웹 개발시 사용 권장되는 디자인 패턴입니다. 사용자의 뒤로가기, 새로고침으로 인한 중복입력을 방지할 수 있습니다. EX) 상품주문 PRG패턴 적용 전 사용자가 상품 주문 juinor.tistory... 2022. 1. 7.
[JBoss] 로깅 문제, 자체적으로 사용하는 로그 라이브러리 제외하기 JBOSS는 자체적으로 로그 모듈을 사용한다. 때문에 slf4j 로그 기능을 사용하는 웹 어플리케이션을 deploy하게 되면 충돌이 발생하여 로그가 제대로 남지 않는다. 따라서 개별 Web Application에 JBOSS 로깅 모듈을 사용하지 않도록 제외 시켜야 한다. 해결방법 1. JBOSS 인스턴스 옵션 추가 JBOSS 시작 옵션에 아래 설정을 추가하여 자체 로그 모듈을 사용하지 않도록 한다. Standalone -Dorg.jboss.as.logging.per-deployment=false 도메인 2. Web Application에 jboss-deployment-structure.xml 추가하여 배포 위치 WAR : WEB-INF/jboss-deployment-structure.xml EAR : M.. 2021. 12. 31.
[Spring Framework] CSRF 적용 지난 번에 spring boot에 csrf를 적용하는 포스팅을 올렸었는데 그냥 spring과 적용하는 방법이 달라 또 포스팅을 올려본다! [Spring Boot] spring security - CSRF 적용 , +) ajax csrf 적용 1. gradle 혹은 maven에 'spring-boot-starter-security' 추가 implementation 'org.springframework.boot:spring-boot-starter-security' org.springframework.boot spring-boot-starter-security 2.5.5 Spring S.. ynzu-dev.tistory.com web.xml에 dispactcher servlet을 등록한다. appServlet.. 2021. 12. 14.
하나의 tomcat에 같은 프로젝트 두개 이상 띄우기 : 'webapp.root' 에러 하나의 톰캣에 같은 프로젝트를 두개 이상 띄었을 때 에러가 발생했다. 심각: Exception sending context initialized event to listener instance of class ch.qos.logback.ext.spring.web.LogbackConfigListener java.lang.IllegalStateException: Web app root system property already set to different value: 'webapp.root' log4j의 default value가 webapp.root라 따로 지정해주지 않는다면 중복된다. 해결방법은 간단한다! web.xml에 아래와 같이 추가해주면 끝! param-value를 지정해주면 된다 webAppR.. 2021. 12. 13.
[Spring Boot] spring security - CSRF 적용 , +) ajax csrf 적용 1. gradle 혹은 maven에 'spring-boot-starter-security' 추가 implementation 'org.springframework.boot:spring-boot-starter-security' org.springframework.boot spring-boot-starter-security 2.5.5 Spring Security는 스프링 기반의 어플리케이션 보안을 담당하는 프레임워크로 Spring Security를 사용하면 보안처리를 간단하면서 강력하게 구현가능하다! 2. XXXXApplication.java에 @EnableWebSecurity 선언 @EnableWebSecurity :Spring Security를 활성화 @EnableWebSecurity @SpringBoot.. 2021. 12. 7.
728x90
반응형