Set up a CDN for Plex with CloudFlare & NGINX

I have QB in a lxc container now as I work my way out of QB and into a full docker config. I use nginx as the reverse proxy for the Dockers so I’ll try to give this a go in that config shortly.

2 Likes

This is working well for Roku, Chromecast and Plex Web. I don’t have any other clients to test locally.

This is why we set the custom access URL - it tells the client where to go for the data. Most clients will still ping the server on port 32400 which is why we have to prevent external access.

I actually had this setup running for a couple weeks but no streams were getting sent through the proxy, only library data. The firewall was the final piece of the puzzle and is not an optional step. Alternately, if you have concerns about your shares, you can simply block port 32400 on your local network. However this shouldn’t be necessary and these steps should enable CF support for all clients.

just curious … seems promising… but what does the average user in this community gain from going down this road? seems like it adds an added layer of complexity … some people have reported bettter performances just from downgrading their plex clients… any thoughts to that? thanks!! again love all the work you guys do… that goes w/o saying… :slight_smile:

I use an OVH server in France. Without the CDN enabled, I usually pull down speeds between 400-1800kb/s from my server. When routed through CloudFlare, Plex rockets to 8MB/s-15MB/s. This translates to insanely faster buffering (most lower bitrate files start within a second) as well as reduced jitter (no random dropouts during streaming).

For me the difference is night and day. Higher bitrate files (eg 20mbps) were not doable (or only under optimal circimstances, but the network would typically change before I was done watching an hour long file). I have no issues now.

Some may see improvements simply with the reverse proxy and not routing their data through CF, though the benefits of CF are very clear in my case - I simply don’t see saturated links at any hour of the day at my location from an OVH France server.

Edit: And you are completely right - it is convoluted. This would be significantly less so if QB ran off nginx (which is a thought kicking around somewhere in the back of my head)

1 Like

interesting so i wonder if many of the problems i was experiencing w/ OVH would go away if i switched to nginx? perhaps good looking into :slight_smile: i’d love to be able to go back to streaming REMUXes w/ minimal problems.

also would it be possible to go back and forth once this is in place for easy A/B testing? or would i be stuck to this once its completed?

thanks Liza.

you forgot an n, im setting up now and got to that step and noticed

on a side note, if i just activated my 2nd ip minutes before doing this guide will it take a little bit before https://plex.mydomain.com works? i followed step by step and both nginx -t tests showed settings working but i am unable to load the url. im not too technical with domain stuff.

1 Like

I’m on OVH, albeit France instead of BHS. I think it depends a bit on what CloudFlare can do for you - for me it is a lot. While CF states that you can use unlimited bandwidth, they also mention that it is a shared service and if you affect users around you they reserve the right to suspend or terminate your account. Remuxes are very data heavy, but if you aren’t streaming them all day every day, then I think you should be able to slip under the radar. Conversely, if CF ever does anything to your account, it would be pretty easy to switch over to a VPS like Vultr where you have a known quantity of bandwidth at your disposal.

As for this, it should be as easy as switching CloudFlare routing on and off through your panel. Make sure you ping the server to make sure if it’s routing through CF or your origin IP (it takes a few moments sometimes for these changes to propagate)

This is related to DNS propagation. It may take a bit of time to get it going. I prefer to use a shorter TTL (time to live) in these circumstances (5 minutes or so) as it helps propagate the change throughout the DNS servers faster. As long as ping is up on the IP, it should propagate through the network eventually.

thanks everything is working here, will have to test out some devices now!

remind me again why the need for Cloudfare? Just curious because it sounds like people like to use NGINX for performance over APACHE. is Cloudfare required in order to run Apache and Nginx side by side?

thanks!

I look forward to your results!

CloudFlare is the CDN - they are the one responsible for routing your data over a faster network and making the server appear much closer to you geographically speaking. Ping to server without CloudFlare: 160ms. With CloudFlare: 15ms. Using them as a proxy server will change the routing of your data to one that hopefully is much better connected than the one provided solely by your DC/ISP.

It would be the same idea as using a VPN (or reverse proxy) to improve speeds.

1 Like

so far it works on browser, phone, xbox one, and roku 3.

does not work on samsung tv which is a problem because thats my main thing i watch on. i have ssl set to full (strict) but the server just shows up as the red X when it works on the roku fine 20 ft away. I am thinking the samsung plex app is more limited than the other apps.

Ah! I forgot I have a Samsung SmartTV too (far prefer the Roku myself). I can’t even communicate with the plex website to login to my account right now. Do you have any other servers (shares or otherwise) on your account to verify it is localized to the proxied server? I have a feeling something fishy is going on with the login portal at the moment.

local server and a remote server setup regular work, but the CF setup is not working on a 2015 JS model. my friend is having no issues playing on his KS (2016) model samsung which uses a different app (new style like roku/xbox). I am thinking there are limitations on this outdated app?

the roku is nice, but I prefer to be a 1 remote kind of guy especially when I am laying in bed.

It’s not working here either (unsure which model we have, probably 2014 or 2015). I wonder if the older models of Samsung TVs don’t support the TLS encryption being forced by CloudFlare.

Aaand Bingo. I disabled CF routing and the server is now visible by the SmartTV client. Looks like your best option is going to be rolling your own reverse proxy on your own VPS where you can dictate the security headers if you want to keep the SmartTV and utilize a “CDN” of sorts.

1 Like

there is an option in the system menu of plex app on the JS model tv to allow secure connections im going to play around with when i get home.

i now worry that the vizio app might possibly not work from my brothers house as well, will have to check on that one.

I think the problem is not secure connections so to speak, the issue is that the SmartTV doesn’t support the level of encryption being forced by the cloudflare proxy. A bit of discussion here is what clued me in to the potential issue along with this issue present on PS4.

im thinking i will probably just roll back the changes all together, i have a hetzner box and dont have any issues streaming just have 5-6 second load time loading some files was hoping this would alleviate it but seems to cause more issues than its worth to figure them out! did not notice any decrease when pinging the server with cf enabled and disabled, its always 135ms average.

but it was nice to run through it and have it actually working for the most part

I wonder would this work with ipv6 ?

CloudFlare supports ipv6 as well as Plex. I see no reason why not :slight_smile: