Embedded YouTube videos don't work unless I un-proxy CF

Brief history
I signed on with Ezoic about 6 months ago, and their system requires me to use Cloudflare. They have an integration dashboard on their end with DNS settings, and if I change something at Ezoic then it automatically changes on CF.

One of the DNS options is “Cloudflare Proxy”.

The problem
The problem I’m having is with embedded YouTube videos. I saw that they all would say “Video Unavailable”, even though they were embedded properly. This is the exact code I used for one such video:

<iframe width="560" height="315" src="https://www.youtube.com/embed/EwKc05_6ItY?si=THVh7s4Xg_zfQ5fa" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>

I recently discovered that if I turn off “Cloudflare Proxy” for the domain, though, all videos would work properly!

I know that CF isn’t supposed to have any impact at all on embedded content, but obviously something’s not working right. Maybe a security thing?

Any suggestions on what I can change or turn off so that I can proxy CF but also embed YouTube?

I’ve found a few other people that have expressed a similar problem, but no resolution. The closest I could find was this thread from last year, where the answer was related to streaming video:

Then I found this, stating that CF doesn’t allow “streaming video content” because it takes up too much bandwidth:

It looks like the solution is to pay for CF Stream:

But this doesn’t make sense. I’m not streaming from my server, I’m just embedding videos that are on YouTube.

Do I have to pay for CF Stream to embed YouTube videos?

No, and it wouldn’t have any effect, either, because, as you already noted, embedded YouTube videos are transferred directly to the visitor from Google servers, never touching the Cloudflare network.

Thanks :slight_smile: Any other thoughts on what could be causing this problem? You can see from that earlier thread that I’m not alone, but if it were a global issue then you’d think a lot more people would be talking about it! So maybe a setting somewhere along the line?

I have some small sites that I can use to experiment if you can think of any setting to change.

Despite having embedded YouTube videos on WordPress behind Cloudflare, I’ve never encountered it, so I have nothing new for you. :man_shrugging:

This site is not proxied through CF, and you can see the YouTube videos work fine:

This domain is parked on top of the first one so this is the exact same page, but this domain IS proxied:

I went through every setting and rule and toggled them, but none of them had an impact. And to my knowledge, the only global setting I’ve made is under Configurations > Lists when I created a list of IPs to be excluded in rules.

Is there a way to escalate this to support? Or a way to contact them even though I only use a free account?

I have good news for future readers that have this problem!

A guy on Reddit figured out the problem. Ezoic is pushing a “Referrer-Policy” of “same-origin”, which YouTube doesn’t allow because it blocks them from seeing where the video is being embedded.

https://www.reddit.com/r/CloudFlare/comments/1c6ol79/comment/l05fg32/?context=3

I was able to fix it by adding this to the header:

Here is an explanation of the different policies:

I could have also fixed it in Cloudflare by going to Rules > Transform Rules > Modify Response Headers. I’m not sure if there’s an advantage to doing it that way instead of a simple META tag, though.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.