Skip to content

Commit

Permalink
fix: 트래픽 중단을 위한 헬스체크 호스트 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
ay-eonii committed Oct 29, 2024
1 parent 5d7f017 commit c7a13f4
Showing 1 changed file with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
@RestController
public class HealthCheckController {

private static final String HOST_IP = "127.0.0.1";
private static final String HOST_IPV4 = "127.0.0.1";
private static final String HOST_IPV6 = "0:0:0:0:0:0:0:1";
private static final String HOST_NAME = "localhost";

private final AtomicBoolean isTerminating = new AtomicBoolean(false);
Expand All @@ -28,12 +29,12 @@ public ResponseEntity<Void> checkHealth() {

@PostMapping("/termination")
public ResponseEntity<Void> terminate(HttpServletRequest request) {
isTerminating.set(true);
return ResponseEntity.ok().build();
// String remoteAddr = request.getRemoteAddr();

// if (HOST_IP.equals(remoteAddr) || HOST_NAME.equals(remoteAddr)) {
// }
// return ResponseEntity.status(HttpStatus.FORBIDDEN).build();
String remoteHost = request.getRemoteHost();
System.out.println(remoteHost);
if (HOST_IPV6.equals(remoteHost) || HOST_IPV4.equals(remoteHost) || HOST_NAME.equals(remoteHost)) {
isTerminating.set(true);
return ResponseEntity.ok().build();
}
return ResponseEntity.status(HttpStatus.FORBIDDEN).build();
}
}

0 comments on commit c7a13f4

Please sign in to comment.