Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Shells Virtual Desktop
BMail.ag - Secure Email Service
Server.net
CPLicense.net
VPS Server
Buy VPN
Vultr
VMs for AI
HostDare
ReliableSite White-Label Dedicated Hosting for Resellers
InterServer VPS
BMail.ag - Secure Email Service
Best VPN
High-Performance Bare Metal Server Solutions
Karvl.com
Server Mania Cloud Hosting
DataWagon Hosting
AlphaVPS Hosting
Evoxt.com
Clouvider
VPS Hosting with NVMe
Residential IPs in the US & 4G Mobile Proxies in EU & US with Unlimited Bandwidth
ReliableSite White-Label Dedicated Hosting for Resellers
Rabisu - Hosting Solutions
Shells Virtual Desktop
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

Plex behind CDN - how to setup?

2

Comments

  • ardaarda Member
    edited March 2017

    @george_zip said:

    arda said: block external access from 32400 plex port from iptables / ufw

    You mean doing something like ufw deny out 32400?

    trewq said: What sort of performance increase are people seeing? Is it just due to better routing?

    I see speed bursts, it reaches my max home internet speed faster than without using CloudFlare. I guess better peering? I have 20Mbit download and I see 80Mbit outgoing bursts on the server when I start streaming video.

    I'm a dinosaur iptables guy:

    iptables -A INPUT -p tcp —dport 32400 -s 192.168.0.0/24 -j ACCEPT
    iptables -A INPUT -p tcp —dport 32400 -s 127.0.0.0/8 -j ACCEPT
    iptables -A INPUT -p tcp —dport 32400 -j DROP
    

    Or something like this (not tested this one):

    iptables -A INPUT -i lo -p tcp --dport 32400 -j ACCEPT
    iptables -A INPUT -p tcp --dport 32400 -j DROP
    

    Allow port's access from inside, block to everywhere else (aka outside).

    @trewq said:
    What sort of performance increase are people seeing? Is it just due to better routing?

    Yes, speedtest mini was giving me approx ~900kb/sec from my server (kimsufi canada) and it was not stable (lags between 400-1200 kb/sec), so plex was slow even with lower bitrates. Changing domain, forcing ssl and using CDN in front of it (I use cloudflare full ssl) helped me max out my local speed, so I get better speeds thanks to routing I guess.

  • @Yoda said:

    Do note that, whilst most apps support it, a select few don't. In my experience the LG smart tv "webOS" app doesn't support it but if you leave port 32400 open then it will fall back.

    It actually does work with LG Smart TVs and PS3/4 over port 80. That's why you need both http and https custom URLs. Those clients don't handle https correctly, so if you have the http URL (you HAVE to specify port 80) they will use that instead. I've tested this extensively with every Plex client.

  • @george_zip said:

    arda said: block external access from 32400 plex port from iptables / ufw

    You mean doing something like ufw deny out 32400?

    trewq said: What sort of performance increase are people seeing? Is it just due to better routing?

    I see speed bursts, it reaches my max home internet speed faster than without using CloudFlare. I guess better peering? I have 20Mbit download and I see 80Mbit outgoing bursts on the server when I start streaming video.

    Make sure you have caching disabled. That can cause the type of bursts you're talking about.

  • Surely it's better to have it blast out into the cache then play back to the client from there.

  • @dragon2611 said:
    Surely it's better to have it blast out into the cache then play back to the client from there.

    Plex doesn't work well with caching due to how the transcoder works. You would think that caching would be a benefit but it's really not. It's caused nothing but headaches when I was trying to get it working.

  • raindog308raindog308 Administrator, Veteran

    This is so LowEnd that I love it.

    For any normal non-cloudflare-free-plan CDN, you wouldn't want to put your personal videos on it because you'd be paying a ton to store and deliver.

    But Cloudflare is free, and apparently has no storage limit for free users...so this is kind of a nice hack to get premium video delivery from your remote Plex.

    No TOS is being violated...just a clever hack.

    image

  • @SprkFade said:

    Make sure you have caching disabled. That can cause the type of bursts you're talking about.

    I did bypass cache on CloudFlare for the domain plex.example.com/*, but I see the bursts again. I’ll see how it goes or if anything changes.

  • @SprkFade said:

    @dragon2611 said:
    Surely it's better to have it blast out into the cache then play back to the client from there.

    Plex doesn't work well with caching due to how the transcoder works. You would think that caching would be a benefit but it's really not. It's caused nothing but headaches when I was trying to get it working.

    Wouldn't that depend on if the clients actually require transcoding or not?

  • SprkFadeSprkFade Member
    edited March 2017

    @raindog308 said:
    This is so LowEnd that I love it.

    For any normal non-cloudflare-free-plan CDN, you wouldn't want to put your personal videos on it because you'd be paying a ton to store and deliver.

    But Cloudflare is free, and apparently has no storage limit for free users...so this is kind of a nice hack to get premium video delivery from your remote Plex.

    No TOS is being violated...just a clever hack.

    There doesn't appear to be any limit on traffic as far as I can tell. Time will tell.

    http://imgur.com/a/GVVVS

    Thanked by 1arda
  • @dragon2611 said:

    @SprkFade said:

    @dragon2611 said:
    Surely it's better to have it blast out into the cache then play back to the client from there.

    Plex doesn't work well with caching due to how the transcoder works. You would think that caching would be a benefit but it's really not. It's caused nothing but headaches when I was trying to get it working.

    Wouldn't that depend on if the clients actually require transcoding or not?

    Even if it does a direct play/stream caching still causes issues. As far as I know, Plex still utilizes a buffer and sends the files in chunks regardless if it's transcoding or not.

  • @george_zip said:

    @SprkFade said:

    Make sure you have caching disabled. That can cause the type of bursts you're talking about.

    I did bypass cache on CloudFlare for the domain plex.example.com/*, but I see the bursts again. I’ll see how it goes or if anything changes.

    Did you disable proxy redirect and buffering in Nginx too?

    proxy_redirect off; proxy_buffering off;

  • @SprkFade said:

    @george_zip said:

    @SprkFade said:

    Make sure you have caching disabled. That can cause the type of bursts you're talking about.

    I did bypass cache on CloudFlare for the domain plex.example.com/*, but I see the bursts again. I’ll see how it goes or if anything changes.

    Did you disable proxy redirect and buffering in Nginx too?

    proxy_redirect off; proxy_buffering off;

    Yes, I did. Playback is smooth for now, even with those bursts. Which apps/platforms had problems when you had caching enabled?

  • @george_zip said:

    @SprkFade said:

    @george_zip said:

    @SprkFade said:

    Make sure you have caching disabled. That can cause the type of bursts you're talking about.

    I did bypass cache on CloudFlare for the domain plex.example.com/*, but I see the bursts again. I’ll see how it goes or if anything changes.

    Did you disable proxy redirect and buffering in Nginx too?

    proxy_redirect off; proxy_buffering off;

    Yes, I did. Playback is smooth for now, even with those bursts. Which apps/platforms had problems when you had caching enabled?

    Web, Roku, FireTV, AppleTV, SmartTV, iOS, PS3/4, Xbox.

  • trewqtrewq Administrator, Patron Provider

    @SprkFade said:

    @Yoda said:

    Do note that, whilst most apps support it, a select few don't. In my experience the LG smart tv "webOS" app doesn't support it but if you leave port 32400 open then it will fall back.

    It actually does work with LG Smart TVs and PS3/4 over port 80. That's why you need both http and https custom URLs. Those clients don't handle https correctly, so if you have the http URL (you HAVE to specify port 80) they will use that instead. I've tested this extensively with every Plex client.

    Could this just be due to not having an SSL that they trust? Seems like it wouldn't be so far out there that they wouldn't have updated their CA to include whatever Cloudflare uses.

  • SprkFadeSprkFade Member
    edited March 2017

    @trewq said:

    @SprkFade said:

    @Yoda said:

    Do note that, whilst most apps support it, a select few don't. In my experience the LG smart tv "webOS" app doesn't support it but if you leave port 32400 open then it will fall back.

    It actually does work with LG Smart TVs and PS3/4 over port 80. That's why you need both http and https custom URLs. Those clients don't handle https correctly, so if you have the http URL (you HAVE to specify port 80) they will use that instead. I've tested this extensively with every Plex client.

    Could this just be due to not having an SSL that they trust? Seems like it wouldn't be so far out there that they wouldn't have updated their CA to include whatever Cloudflare uses.

    I know that the PS4 has certificate trust issues, but the older Vizio TVs just don't support it and it crashes the app.

  • Here is my question, why?

  • ardaarda Member

    @AlyssaD said:
    Here is my question, why?

    Fully encrypted traffic, and thanks to CDNs increased speed.

  • @AlyssaD said:
    Here is my question, why?

    It improves peering and streaming performance significantly for people that have poor peering or slower internet between Cloudflare and using Nginx.

  • @arda said:

    @AlyssaD said:
    Here is my question, why?

    Fully encrypted traffic, and thanks to CDNs increased speed.

    But in reality it really won't..... As that isn't how Plex works. Plex will go around the CDN to the backend server for the files. That is unless you specifically setup Plex to use a domain name and setup nginx as a reverse proxy on the Plex host. Further, you would also at that point lose some functionality mostly in regards to how Plex knows how to stream to your device. This functionality determines how good the encoding needs to be for your device.

    If you are having issues with Plex as it is the much better option is by going and changing direct play to off. You can do this by going to settings and turning off Allow Direct Streaming/Allow Direct Play. This will force all files to be converted, and generally save bandwidth. You can also tinker and bring down the quality level.

  • I tried using plex over a CDN a year ago and had to use Incapsula since Cloudflare at the time didn't offer websocket support. Then soon after Cloudflare added support.

    Your CDN must support websockets (unless it has changed with what Plex requires).

    I had contacted some people on the plex forums and eventually was able to get one of the methods to work. At the time, I was using Hetzner with Cloudflare and it didn't really add much to the speed differences and was a kind of intrusive method just to get the CDN working.

    https://gist.github.com/Doonga/dc91f2c52f17c9931e269966dfcb956d

    Now that I think of it, it might've never gone through the CDN but this is your only option sadly since the older ones were for making non-ssl Plex into SSL plex.

  • ardaarda Member

    @AlyssaD said:

    @arda said:

    @AlyssaD said:
    Here is my question, why?

    Fully encrypted traffic, and thanks to CDNs increased speed.

    But in reality it really won't..... As that isn't how Plex works. Plex will go around the CDN to the backend server for the files. That is unless you specifically setup Plex to use a domain name and setup nginx as a reverse proxy on the Plex host. Further, you would also at that point lose some functionality mostly in regards to how Plex knows how to stream to your device. This functionality determines how good the encoding needs to be for your device.

    If you are having issues with Plex as it is the much better option is by going and changing direct play to off. You can do this by going to settings and turning off Allow Direct Streaming/Allow Direct Play. This will force all files to be converted, and generally save bandwidth. You can also tinker and bring down the quality level.

    Traffic between CF and upstream plex is also encrypted. And It increased the speed for me. What's the issue here ? CF's CDN servers fetch faster than me, and copy to a location where I can stream faster.

    I block 32400 plex port to outside from my plex server, and use this way. Works nicely on desktop app (Windows and macOS), web ui, and Android app. I can't say much about Samsung TV apps etc. since I don't own them.

    And no, I don't have issues with Plex. My server is strong enough to transcode ~2 1080p movies simultaneously. As I've mentioned earlier, I'd suggest everyone to try speedtest mini client or a similar tool first to test their download speed between their server and their end. If it's slow, and you think it shouldn't and it's a result of bad peering, this CF/whateverCDN trick will help you out.

  • @AlyssaD said:

    @arda said:

    @AlyssaD said:
    Here is my question, why?

    Fully encrypted traffic, and thanks to CDNs increased speed.

    But in reality it really won't..... As that isn't how Plex works. Plex will go around the CDN to the backend server for the files. That is unless you specifically setup Plex to use a domain name and setup nginx as a reverse proxy on the Plex host. Further, you would also at that point lose some functionality mostly in regards to how Plex knows how to stream to your device. This functionality determines how good the encoding needs to be for your device.

    If you are having issues with Plex as it is the much better option is by going and changing direct play to off. You can do this by going to settings and turning off Allow Direct Streaming/Allow Direct Play. This will force all files to be converted, and generally save bandwidth. You can also tinker and bring down the quality level.

    You don't lose ANY functionality using it this way. Honestly, there isn't a single downside to this configuration other than the time it takes you to set it up. It improves peering, which in turn can help people with crappy internet, and it also speeds up overall performance since Nginx is doing a lot of the work.

  • I mean... I have. I get far less performance out of Cloudflare. In my many previous tests, going directly to my servers were better. Though, I don't buy these super cheap servers with hosts that have terrible networks.

  • @AlyssaD said:
    Though, I don't buy these super cheap servers with hosts that have terrible networks.

    Just curious, which hosts do you use? I mean if you use them specifically for Plex and streaming.

    Thanked by 1raphaj
  • AlyssaDAlyssaD Barred
    edited March 2017

    I have used tons of hosts, and commonly the issue was CF was slower. The advantage always was free bandwidth, and the ability to scale if you had dozens of people downloading the same file.

    1. Nocix, was faster than using cf.
    2. Incero was faster than using cf.
    3. I think even decentec was faster than using cf.
  • ardaarda Member
    edited March 2017

    @AlyssaD said:
    I mean... I have. I get far less performance out of Cloudflare. In my many previous tests, going directly to my servers were better. Though, I don't buy these super cheap servers with hosts that have terrible networks.

    It's also about far away locations. E.g: in my case, I live in eastern EU region, and my server is in Canada.

  • @arda said:

    @AlyssaD said:
    I mean... I have. I get far less performance out of Cloudflare. In my many previous tests, going directly to my servers were better. Though, I don't buy these super cheap servers with hosts that have terrible networks.

    It's also about far away locations. E.g: in my case, I live in eastern EU region, and my server is in Canada.

    Yeah, in my case CloudFlare helps when streaming from Hetzner to EU and Canada, otherwise Hetzner to EU only is completely fine without CF.

  • Hey guys, thanks for all replies.

    I just want say thank you for @arda by help me with the tutorial step by step for getting plex working behind cloudflare and another cdn solutions and for their patience with me.

    I love this forum. You guys are great.

    Thanks a lot. :D

    Thanked by 1arda
  • I'm working on a project to deploy a multi-user docker based seedbox script. I use Traefik as the front end to a docker based plex and other scripts on the backend. Setting up this CDN was a snap..literally one line needed to be added to my docker run script and then the CloudFlare setup side of it.

  • @RXWatcher said:
    I'm working on a project to deploy a multi-user docker based seedbox script. I use Traefik as the front end to a docker based plex and other scripts on the backend. Setting up this CDN was a snap..literally one line needed to be added to my docker run script and then the CloudFlare setup side of it.

    I'm interested.

Sign In or Register to comment.