Skip to content

RTC: Ensure private network requests are made from secure contexts #2787

Description

@winlinvip

Today I discovered that Chrome updated its security policy in July 2021, which caused the HTTPS player on the official website to be unable to play the SRS stream on the local network. Of course, this does not mean that it cannot be used at all. I will list which ones are working properly and which ones have issues (assuming your SRS local network IP is 192.168.11.172):

Note: The mentioned "play HTTP API" refers to the API for WebRTC streams, which is an HTTP API. The transmission of the streams still uses UDP.

The last point is about playing SRS streams from an internal network using the official HTTP player. This issue is related to the security policy update made by Chrome a few months ago. If you open the console, you will see the following error message.

Ensure private network requests are made from secure contexts

A site requested a resource from a network that it could only access because of its users' privileged 
network position. These requests expose devices and servers to the internet, increasing the risk of a 
cross-site request forgery (CSRF) 
attack, and/or information leakage.

To mitigate these risks, Chrome deprecates requests to non-public subresources when initiated from 
non-secure contexts, and will start blocking them in Chrome 92 (July 2021).

To fix this issue, migrate the website that needs to access local resources to HTTPS. If the target resource 
is not served on localhost, it must also be served on HTTPS to avoid mixed-content issues.

Administrators can make use of the InsecurePrivateNetworkRequestsAllowed and 
InsecurePrivateNetworkRequestsAllowedForUrls enterprise policies to temporarily disable this restriction 
on all or certain websites.


1 request
Request	Status	Resource Address	Initiator Address	Initiator Context
play/	blocked	Private	Public	insecure

Learn more: CORS for private networks (RFC1918)

I have tried adding parameters to the page, but it didn't work.

    <meta name="referrer" content="origin">

Here is an alternative workaround: If you are only developing, debugging, and learning, you can follow the method taught by Darren, a teacher at Zero Sound Academy. Simply disable HTTPS and all security policies when starting Chrome, which works well.

If it is for online use, it is better to stick to HTTPS honestly.

References:

TRANS_BY_GPT3

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

DiscussionDiscussion or questions.TransByAITranslated by AI/GPT.WebRTCWebRTC, RTC2RTMP or RTMP2RTC.Won't fixWe won't fix it.

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions