no image
headers-more-nginx-module docker image
headers-more-nginx-modulenginx에서 특정 헤더에 값을 수정할 수 있는 모듈이다.nginx에 포함되지 않은 third-party 모듈로 별도 설치가 필요하다. 도커로 nginx를 사용할 때 외부 모듈을 사용하려면, 모듈이 설치된 도커 이미지를 만들어야 한다.고맙게도 nginx 공식 repo에서 작성해 둔 Dockerfile이 있다.https://github.com/nginxinc/docker-nginx/tree/master/modules docker-nginx/modules at master · nginxinc/docker-nginxOfficial NGINX Dockerfiles. Contribute to nginxinc/docker-nginx development by creati..
2024.12.21
no image
nginx reverse proxy로 CORS 해결하기
내용 들어가기 전 용어 정의Domain최상위 도메인(TLD: Top-Level Domain) : 인터넷 주소를 분류하는 역할을 한다.ex) .com, .org, .net, .edu, .kr, .jp, .uk  2차 도메인(SLD: Second-Level Domain) : 조직 또는 웹사이트의 고유 이름을 나타낸다.ex) goole, naver, tistory, youtube 서브 도메인 : 주 도메인의 하위 영역을 나타낸다. 루트 도메인 : 도메인의 기본 주소로, 보통 SLD + TLD 조합으로 이루어진다. SOP (Same-Origin Policy)웹 브라우저가 보안을 위해 출처가 같은 리소스에 대해서만 요청을 허용하는 정책이다.동일 출처는 프로토콜, 도메인, 포트가 모두 동일한 경우를 의미한다. A ..
2024.12.03
no image
kafka-spring Producer key에 따른 partition 배정
카프카 producer key CompletableFuture future = kafkaTemplate.send(MSG_TOPIC, key, msg.getMsg()); future.whenComplete((result, ex) -> { System.out.println("future : " + result.getProducerRecord().value()); }); producer에 key가 있을 수도 있고 없을 수도 있다. 있다면 그 key로 해시값을 만들어 동일한 key라면 동일한 partition에 메세지를 전송할 수 있고 없으면 메세지를 라운드로빈으로 적절히 파티션들에 분산시키는 듯 하다. Consumer partition @Bean public NewTopic messageTopic() { re..
2023.09.03
docker bitnami/kafka 주키퍼없이(KRaft)
KRaft 모드 카프카에 대해 조사를 해보면 카프카의 메타 데이터, 브로커 상태, 토픽 상태 등을 관리하기 위해 주키퍼를 사용하는 것을 볼 수 있다. 그런데 docker kafka 이미지들을 보면 zookeeper 없이 구성된 docker-compose를 볼 수 있는데 카프카의 최근 버전에서는 주키퍼 없이 카프카를 사용할 수 있는 구조를 지향한다고 한다. 그래서 주키퍼없이 자체적으로 메타데이터를 관리하기 위해 만들어진 것이 KRaft 모드이고 QUORUM 컨트롤러는 KRaft 와 관련된 키워드이다. bitnami/kafka services: kafka: image: bitnami/kafka:latest ports: - '9092:9092' environment: # KRaft settings - KAFK..
2023.09.02
spring kafka - @KafkaListener Annotation
@KafkaListener Annotation 많은 consumer의 방법 중 하나이다. @KafkaListener(id = "foo", topics = MSG_TOPIC, clientIdPrefix = "myClientId") public void listen(String data) { System.out.println(data); } 사용 방법은 다음과 같다. id는 GROUP_ID_CONFIG 와 같다. 그래서 kafkaListener에서 지정하면 consumerConfig에서 group id 설정을 빼야한다. [Consumer clientId=myClientId-0, groupId=foo] [Consumer clientId=myClientId-1, groupId=foo] [Consumer clie..
2023.09.02
no image
docker-compose nginx load-balancing (spring, node, ws)
nginx.conf user nginx; worker_processes auto; error_log /var/log/nginx/error.log notice; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log..
2023.08.28
Kafka의 아키텍처를 알아보자
Kafka zookeeper kafka cluster brocker topic partition producer consumer group consumer zookeeper 위와 같은 역할을 하는 요소들이 있다. 각각의 역할을 보자. 카프카 = kafka cluster 이고 카프카를 여러개 띄웠을 때 관리하는 역할이 zookeeper이다. Broker kafka cluster는 여러개의 브로커를 가질 수 있고 브로커는 topic 으로 메세지를 구분한다. 한 개의 topic은 한 개 이상의 파티션으로 구성돼있고 파티션은 기본적으로 추가만 가능한 공간이다. 파티션에 저장된 메세지의 저장 위치를 오프셋 이라고 한다. 컨슈머가 파티션을 소비해도 메세지는 삭제되지 않는다. topic의 특정 파티션에 저장하려면 키..
2023.08.11
no image
OAuth2를 알아보자
OAuth(Open Authorization)는 접근 위임을 위한 프로토콜의 일종이다.내 서버 입장에서는 Third-Party Application을 통해 내 서버에 대해 접근을 위임하는 것이고Third-Party Application 입장에서는 리소스 소유자를 대신해 리소스 서버에서 제공하는 자원에 대한 접근 권한을 위임하는 것이다.구성 역할Resource Onwer : 사용자Client : 나의 Application (나의 Application에서 서버와 클라이언트 둘 다 의미한다.)Authorization Server : 인증/인가를 수행하는 서버로 사용자는 Authorization Server에 ID, PW를 전송해 Client로 인가 코드를 발급 받을 수 있고 Client는 인가 코드를 Aut..
2023.07.25