본문 바로가기

Work/개발 노트92

[nginx] 정규표현식으로 패턴 매치 후 proxy pass 시 쿼리 파라미터 포함하기 Nginx를 사용하면서 패턴에 매치하는 Request를 Proxy pass로 전달 할 때 쿼리 파라미터가 포함되지 않아 어플리케이션 레벨의 문제인 것으로 생각하고 한참을 고생했다. 여기서 쿼리 파라미터는 아래 예로 든 주소에서 물음표(?) 뒤에 오는 키-값들을 의미한다. https://yongho1037.tistory.com/manage/newpost/?type=post&returnURL=%2Fmanage%2Fposts%2F 문제가 되었던 nginx 설정은 다음과 같다. location ~ /(api|login|auth)/(.*)$ { proxy_pass http://backend/$1/$2; proxy_set_header Host $host; proxy_set_header X-Forwarded-For .. 2020. 9. 28.
[k8s] Image Pull 실행 시 ECR 로그인 적용하기 여러 팀과 함께 서비스를 운영하다보면 현재 사용 중인 서버가 속한 AWS Account 외에 다른 Account의 ECR에 존재하는 컨테이너 이미지를 Pull 받아야하는 경우가 있다. 이 때 해당 Account에서 ECR의 read only 권한을 가진 IAM User의 Access Key를 사용하여 로그인을 수행한 후 컨테이너 이미지를 Pull 받을 수 있다. 먼저 ~/.aws/credentials 파일에 default 또는 별도 profile을 지정하여 Access Key를 등록한다. [ecr-readonly] aws_access_key_id = aws_secret_access_key = 다음 명령으로 ECR에 로그인 한다. aws ecr get-login-password --region ap-nor.. 2020. 9. 26.
[Go언어] embedded struct bson marshaling 시 struct 이름으로 키가 생성되는 문제 아래와 같이 Sample struct에서는 Inner struct를 embedded 하고 있다. type Inner struct { ID string `json:"id,omitempty" bson:"_id,omitempty" Name string `json:"name" bson:"name"` CreatedAt int64 `json:"created_at,omitempty" bson:"created_at,omitempty"` ModifiedAt int64 `json:"modified_at,omitempty" bson:"modified_at,omitempty"` } type Sample struct { Inner } 이 때 marshaling을 수행하면 json의 경우에는 아래와 같이 원하는 대로 변환 된다... 2020. 9. 18.
[Go언어] tcp로 웹 서버 구동시 tcp6로 Listen Golang echo framework로 웹 서버 실행 시 tcp를 지정하여 IPv4를 사용하도록 설정을 했는데도 서버가 실행된 후 LISTEN 상태를 보면 아래와 같이 tcp6만 실행되어있다. netstat -anp | grep 8080 (Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.) tcp6 0 0 :::8080 :::* LISTEN - 그럼에도 ACL이 허용된 다른 서버에서 telnet으로 접근을 시도하면 정상적으로 접근이 된다. telnet 10.0.13.35 8080 Trying 10.0.13.35... Connected t.. 2020. 9. 14.