frigate-hass-addons icon indicating copy to clipboard operation
frigate-hass-addons copied to clipboard

Frigate Proxy - Error with proxy domain

Open Ixian opened this issue 3 years ago • 2 comments

This might be a bit of an edge case but I found a problem with the Frigate Proxy addon (which I love, btw):

If you are using your own proxy/custom url in front of Home Assistant (I use Traefik 2) and access it via your own domain like hassio.mydomain.com via said proxy you get hundreds of X-Frame errors with this addon -

Some browsers (Firefox) throw up random errors loading videos from the recordings page, others (Chrome) just log to console from what I can tell though it's probable there are other issues I haven't seen.

This is because nginix needs the add_header Content-Security-Policy "frame-ancestors domain.com"; directive set (for modern browsers) and/or add_header X-Frame-Options "ALLOW-FROM domain.com"; for older browsers to allow the custom domain through.

I ssh'd in to my Hassio box and opened a shell in the container: docker exec -it <proxy-container-id> /bin/bash

And added the following to /etc/nginx/includes/server-params.conf

add_header Content-Security-Policy "frame-ancestors hassio.mydomain.com";

then restarted nginx

nginx -s reload

And the errors went away in the browser console, along with the problems loading videos, etc.

Since this change won't persist what I'm thinking is you could allow users to add their proxy url to options.json via the config interface just like you do with the server global now. If a user sets that option, add the header line to the conf.

If you want me to take a crack at it and submit a pull I can but thought I would ask since this would probably be simple for you do do.

Thanks again for the work on Frigate!

Ixian avatar Sep 20 '21 22:09 Ixian

A PR would be great if you have time. Thanks for taking the time track it down.

blakeblackshear avatar Sep 20 '21 22:09 blakeblackshear

I submitted a draft PR for your review, thanks again for all your work on Frigate!

Ixian avatar Sep 21 '21 17:09 Ixian