Hosting and media

CloudFlare

Proxy and cache settings that affect streaming

CloudFlare is a popular content delivery network (CDN) and security service that provides a range of features to enhance website performance and security. However, when your RamTV is installed on a domain proxied through CloudFlare, certain issues can arise:

  1. Real IP Address Not Passed: By default, CloudFlare masks the real IP addresses of users, passing CloudFlare IPs instead. This can break functionalities in your RamTV that rely on users' real IP addresses.
  2. Page and Endpoint Caching: if you add Cloudflare cache rules for pages, API endpoints or protected media, visitors can receive someone else's cached response. Keep caching to static files (Cloudflare's default) — see the recommended settings below.

With Cloudflare support turned on, RamTV reads each visitor's real IP address from Cloudflare's CF-Connecting-IP header — but only for requests that really arrive from Cloudflare's network, so nobody can fake an address by going around Cloudflare. Real addresses matter for the firewall, session IP locks, IP geolocation, HLS keys and download links.

Enabling CloudFlare Support

Follow the steps below to enable CloudFlare support in RamTV:

1. Locate the Configuration File: Navigate to the ~ramtv/api/app/ directory

2. Edit the User Configuration File: Open config_user.php in a text editor.

3. Modify the CloudFlare Cache Setting: 

Find the line:

define( "cf_cache", false ); 

Change it to:

define( "cf_cache", true );

Save and Close the File

4. Clear CloudFlare Cache:

It may be beneficial to clear CloudFlare’s cache to ensure the new settings take immediate effect. This can be done through the CloudFlare dashboard by navigating to the Caching section and selecting the "Purge Everything" option.

  • Don't add cache rules for /api/, /admin/, /files/protected/, /files/hls_keys/, protector.php or hls_key.php. Cloudflare's default (static files only) is what RamTV expects.
  • Cloudflare's Free and Pro plans reject uploads larger than 100 MB in a single request. If you or your users upload larger files, turn on Setting → Files → Upload Setting → Chunk upload and set the chunk size below 100 MB.
  • After changing these settings, use Purge Everything once so no old copies are left.