Secure OpenReplay
Configure SSL
Section titled Configure SSLIf you’re bringing your own certificate, create an SSL secret using the following command: kubectl create secret tls openreplay-ssl -n app --key="private_key_file.pem" --cert="certificate.crt".
Note: If you don’t have a certificate, generate one, that auto-renews, for your subdomain (the one provided during installation) using Let’s Encrypt. Simply connect to OpenReplay instance, run
cd openreplay/scripts/helmcharts && bash certmanager.shand follow the steps.
If you wish to enable http to https redirection (recommended), then uncomment the below block, under the ingress-nginx section, in openreplay/scripts/helmcharts/vars.yaml:
ingress-nginx: &ingress-nginx
controller:
config:
ssl-redirect: true
force-ssl-redirect: true
Note: Our
ingress-nginxruns by default on ports80|443, but this can be easily changed, if needed, invars.yaml:
ingress-nginx: &ingress-nginx
controller:
service:
ports:
http: 80
https: 443
Finally reinstall NGINX:
cd openreplay/scripts/helmcharts && ./openreplay-cli -I
Set reCaptcha
Section titled Set reCaptchaOpenReplay supports reCaptcha (v2) for additional security. To enable this protection:
- Open
openreplay/scripts/helmcharts/vars.yamlthen uncomment and update the below env variables inchalicesection:
captcha_server: The URL to your reCaptcha service (e.g. https://www.google.com/recaptcha/api/siteverify)captcha_key: You reCaptcha secret key
- Edit
env.jsinopenreplay/frontend/and substitute theCAPTCHA_SITE_KEYvariable with your reCaptcha site key. - Rebuild the frontend:
cd openreplay/frontend
IMAGE_TAG=my-custom-image PUSH_IMAGE=1 DOCKER_REPO=my-docker-user-name bash -x build.sh
- Open
openreplay/scripts/helmcharts/vars.yamland specify your newly built frontend image in thefrontendblock:
frontend:
image:
repository: "my-docker-username/frontend"
tag: "my-custom-image"
- Restart the frontend and web server services for the changes to take effect:
cd openreplay/scripts/helmcharts && ./openreplay-cli -I
Content Security Policy (CSP)
Section titled Content Security Policy (CSP)Here is an example of a policy (CSP) for allowing OpenReplay to record sessions. This has to be adapted depending on your domain and security requirements:
worker-src ‘self’ blob: https://openreplay.mycompany.com https://*.openreplay.com; script-src ‘self’ https://openreplay.mycompany.com https://*.openreplay.com;
To apply your CSP to NGINX, connect to your OpenReplay instance and follow the below steps:
- Open
openreplay/scripts/helmcharts/vars.yamland add your CSP in thefrontendblock. Make sure to update
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;";
Note: Make sure to replace
https://openreplay.mycompany.comoccurences in the above CSP with your OpenReplay domain name. The value should be the same asDOMAIN_NAMEinopenreplay/scripts/helmcharts/vars.yamlfile.
- Reinstall NGINX to apply your newly added CSP:
cd openreplay/scripts/helmcharts && ./openreplay-cli -I
Enabling CORS
Section titled Enabling CORSCross-domain requests are allowed, by default, from all origins (Access-Control-Allow-Origin: *). If you wish to restrict recordings from few domains only, then open openreplay/scripts/helmcharts/vars.yaml and update the http block as below:
http:
ingress:
annotations:
nginx.ingress.kubernetes.io/enable-cors: "true"
nginx.ingress.kubernetes.io/cors-allow-origin: "https://origin-site1.com:443, http://origin-site2.com"
Then, reinstall NGINX:
cd openreplay/scripts/helmcharts && ./openreplay-cli -I