OpenReplay 보안 설정
노드 접근 제한
Section titled 노드 접근 제한보안 그룹을 사용하여 머신에서 80/443 포트만 열어 두는 것을 강력히 권장합니다. k3s 서버 API, flannel API 등 일부 구성 요소는 네트워킹을 쉽게 하려고 0.0.0.0 주소에서 수신 대기합니다.
SSL 구성
Section titled SSL 구성보유한 인증서를 사용하는 경우 다음 명령으로 SSL 시크릿을 생성합니다: kubectl create secret tls openreplay-ssl -n app --key="private_key_file.pem" --cert="certificate.crt".
참고: 인증서가 없다면 Let’s Encrypt를 사용해 서브도메인(설치 중에 지정한 서브도메인)용 인증서를 자동 갱신 방식으로 발급받을 수 있습니다. OpenReplay 인스턴스에 접속하여
cd openreplay/scripts/helmcharts && bash certmanager.sh를 실행하고 안내에 따르면 됩니다.
http에서 https로의 리디렉션을 활성화하려면(권장) ingress-nginx 섹션 아래의 다음 블록 주석을 해제합니다.
ingress-nginx: &ingress-nginx
controller:
config:
ssl-redirect: true
force-ssl-redirect: true
참고:
ingress-nginx는 기본적으로80|443포트에서 실행되지만, 필요하다면openreplay -e에서 쉽게 변경할 수 있습니다.
ingress-nginx: &ingress-nginx
controller:
service:
ports:
http: 80
https: 443
:wq를 입력해 저장하고 종료하면 서비스가 다시 로드됩니다.
X-Frame-Options 강화
Section titled X-Frame-Options 강화브라우저가 <frame>, <iframe>, <embed> 또는 <object> 안에서 페이지를 렌더링하도록 허용할지 여부를 지정하고 클릭재킹 공격을 방지하려면, openreplay -e로 구성을 수정하여 X-Frame-Options 응답 헤더를 설정합니다.
ingress-nginx: &ingress-nginx
controller:
addHeaders:
X-Frame-Options: "SAMEORIGIN"
그런 다음 :wq를 입력해 저장하고 종료하면 서비스가 다시 로드됩니다.
reCaptcha 설정
Section titled reCaptcha 설정OpenReplay는 추가 보안을 위해 reCaptcha(v2)를 지원합니다. 이 보호 기능을 활성화하려면 다음과 같이 합니다.
- Google에서 v2 reCaptcha 키를 발급받고
invisible모드를 활성화합니다. 즉,tick I am not a human을 표시하지 않도록 합니다. openreplay -e를 실행한 다음chalice섹션의 아래 환경 변수의 주석을 해제하고 값을 수정합니다.
captcha_server: reCaptcha 서비스의 URL (예: https://www.google.com/recaptcha/api/siteverify)captcha_key: reCaptcha 시크릿 키
openreplay/frontend/의.env를 수정하고(없으면.env.sample을 복사합니다)CAPTCHA_SITE_KEY변수를 reCaptcha 사이트 키로 바꿉니다.- 프런트엔드를 다시 빌드합니다.
cd openreplay/frontend
IMAGE_TAG=my-custom-image PUSH_IMAGE=1 DOCKER_REPO=my-docker-user-name bash -x build.sh
openreplay -e를 실행하고frontend블록에 새로 빌드한 프런트엔드 이미지를 지정합니다.
frontend:
image:
repository: "my-docker-username/frontend"
tag: "my-custom-image"
- 변경 사항이 적용되도록 프런트엔드와 웹 서버 서비스를 재시작합니다.
openreplay -R
콘텐츠 보안 정책(CSP)
Section titled 콘텐츠 보안 정책(CSP)다음은 OpenReplay가 세션을 녹화할 수 있도록 허용하는 정책(CSP) 예시입니다. 도메인과 보안 요구 사항에 맞게 수정해야 합니다.
worker-src ‘self’ blob: https://openreplay.mycompany.com https://*.openreplay.com; script-src ‘self’ https://openreplay.mycompany.com https://*.openreplay.com;
CSP를 NGINX에 적용하려면 OpenReplay 인스턴스에 접속하여 다음 단계를 따릅니다.
openreplay -e를 실행하고frontend블록에 CSP를 추가합니다. 반드시 다음 항목을 업데이트하세요.
frontend:
ingress:
cspSnippet: |
add_header Content-Security-Policy "worker-src 'self' blob: https://openreplay.mycompany.com https://*.openreplay.com; script-src 'self' https://openreplay.mycompany.com https://*.openreplay.com;";
참고: 위 CSP의
https://openreplay.mycompany.com을 반드시 사용 중인 OpenReplay 도메인 이름으로 바꾸세요. 이 값은openreplay -e를 실행할 때의DOMAIN_NAME과 같아야 합니다.
:wq를 입력해 저장하고 종료하면 새로 추가한 CSP가 적용됩니다
CORS 활성화
Section titled CORS 활성화기본적으로 모든 오리진(Access-Control-Allow-Origin: *)에서 오는 교차 도메인 요청이 허용됩니다. 일부 도메인에서만 녹화를 허용하려면 openreplay -e를 실행하고 http 블록에 아래 어노테이션을 추가하여 수정합니다.
http:
ingress:
annotations:
nginx.ingress.kubernetes.io/cors-allow-methods: POST
nginx.ingress.kubernetes.io/cors-allow-headers: Content-Type,Authorization,Content-Encoding
nginx.ingress.kubernetes.io/cors-allow-origin: https://app1.mycompany.com,https://app2.mycompany.com,https://*.mycompany.com
nginx.ingress.kubernetes.io/enable-cors: "true"
nginx.ingress.kubernetes.io/cors-expose-headers: "Content-Length"
그런 다음 :wq를 입력해 저장하고 종료하면 새로 추가한 CSP가 적용됩니다.
궁금한 점이 있으신가요?
Section titled 궁금한 점이 있으신가요?이 과정에 대해 궁금한 점이 있으시면 언제든지 Slack으로 문의해 주세요.