PHP allow file_get_contents from a remote server I own [duplicate] - Hack The Tech - Latest News related to Computer and Technology

Hack The Tech - Latest News related to Computer and Technology

Get Daily Latest News related to Computer and Technology and hack the world.

Thursday, October 12, 2023

PHP allow file_get_contents from a remote server I own [duplicate]

I currently run a server which has files I'd like to get (mostly m3u8) and I have a .htaccess referrer blocking any sites from accessing my content apart from my own domains. I have recently decided to echo out the m3u8 files on my main server, however it's giving me a 403 forbidden, which makes sense as I have blocked access, however my main site is in the referrers so there's no reason why it would be blocking the file_get_contents ?

This is the error my file_get_content is throwing:

failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden 

This is my .htaccess setup:

<IfModule mod_headers.c>
    Header set Access-Control-Allow-Origin "*"
</IfModule>

RewriteEngine On
RewriteCond "%{HTTP_REFERER}" "!example.com"
RewriteRule ^.*$ - [F]

The code I'm trying to execute:

<?php
echo file_get_content('https://storage.example.com/videos/title/master.m3u8')
?>

With the expected result of:

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:19
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:19.437378,
master-P000.ts
#EXTINF:10.386067,
master-P001.ts
#EXTINF:2.586089,
master-P002.ts
#EXTINF:8.675911,
master-P003.ts
#EXTINF:10.427778,
...

But, these videos do play from my referring site:

https://example.com plays video from https://storage.example.com/videos/title/master.m3u8

If I remove my .htaccess for testing sake, the file_get_content works with no problem at all.



source https://stackoverflow.com/questions/77275537/php-allow-file-get-contents-from-a-remote-server-i-own

No comments:

Post a Comment