Reorganize the SRS (Simple Realtime Server) repository to follow a conventional Go project structure, setting the stage for a progressive transition from a C++ project to a Go project. The proxy, which was once contained within its own `proxy/` subdirectory, will now be converted into the initial Go module located at the root of the repository, serving as a template for subsequent Go modules. - **Go module at repo root:** `go.mod` moved to repo root, module renamed from `proxy` to `srsx`. The repo is now a proper Go project with `cmd/` and `internal/` at the top level. - **Elevation of Proxy Code:** Move the proxy code from `proxy/cmd/proxy-go/` to `cmd/proxy/`, and from `proxy/internal/` to `internal/`. The proxy serves as the inaugural application; subsequent modules (for instance, `cmd/origin`) will mimic this arrangement. - **Documentation Restructured:** Transfer the documentation from `proxy/docs/` to `docs/proxy/`, revise the main README to endorse OpenClaw as the preferred AI tool, and update `proxy/README.md` to point to the new documentation locations. - **Build and config:** `Makefile` moved to root, `PROXY_STATIC_FILES` default path corrected for the new layout, `.gitignore` consolidated. - **Cleanup:** removed standalone `proxy/LICENSE` (repo-level license applies), all internal imports updated to `srsx/internal/...`. - **OpenClaw workspace:** added community bot info, git workflow conventions, and support group behavior guidance. This restructuring was performed by OpenClaw orchestrating Claude Code and Codex via ACP. --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com>
5.7 KiB
Origin Cluster
How to use the proxy server to build an origin cluster for SRS media server.
Build
To build the proxy server, you need to have Go 1.18+ installed. Then, you can build the proxy
server by below command, and get the executable binary ./srs-proxy:
cd ~/git &&
git clone https://github.com/ossrs/srs.git &&
cd proxy && make
Note: You can also download the dependencies by running
go mod downloadbefore building.
We will support the Docker image in the future, or integrate the proxy server into the Oryx project.
Clone and build SRS, which is the default backend origin server:
cd ~/git &&
git clone https://github.com/ossrs/srs.git &&
cd srs/trunk && ./configure && make
SRS will automatically register itself to the proxy server, see Automatic Registration in proxy-protocol.md.
You can use any other RTMP server as the backend origin server, but you need to register the backend server manually, see Manual Registration API in proxy-protocol.md.
Legacy
From SRS 7.0+, the new Origin Cluster is based on proxy server, not the old MESH based SRS servers. However, if you want to use the old origin cluster, you can switch to SRS 6.0.
RTMP Origin Cluster
To use the RTMP origin cluster, you need to deploy the proxy server and the origin server. First, start the proxy server:
env PROXY_RTMP_SERVER=1935 PROXY_HTTP_SERVER=8080 \
PROXY_HTTP_API=1985 PROXY_WEBRTC_SERVER=8000 PROXY_SRT_SERVER=10080 \
PROXY_SYSTEM_API=12025 PROXY_LOAD_BALANCER_TYPE=memory ./srs-proxy
Note: Here we use the memory load balancer, you can switch to
redisif you want to run more than one proxy server.
Then, deploy three origin servers, which connects to the proxy server via port 12025:
./objs/srs -c conf/origin1-for-proxy.conf
./objs/srs -c conf/origin2-for-proxy.conf
./objs/srs -c conf/origin3-for-proxy.conf
Note: The origin servers are independent, so it's recommended to deploy them as Deployments in Kubernetes (K8s).
Now, you're able to publish RTMP stream to the proxy server:
ffmpeg -re -i doc/source.flv -c copy -f flv rtmp://localhost/live/livestream
And play the RTMP stream from the proxy server:
ffplay rtmp://localhost/live/livestream
Or play HTTP-FLV stream from the proxy server:
ffplay http://localhost:8080/live/livestream.flv
Or play HLS stream from the proxy server:
ffplay http://localhost:8080/live/livestream.m3u8
Or play the WebRTC stream via WHEP player from proxy server.
You can also use VLC or other players to play the stream in proxy server.
WebRTC Origin Cluster
To use the WebRTC origin cluster, you need to deploy the proxy server and the origin server. First, start the proxy server:
env PROXY_RTMP_SERVER=1935 PROXY_HTTP_SERVER=8080 \
PROXY_HTTP_API=1985 PROXY_WEBRTC_SERVER=8000 PROXY_SRT_SERVER=10080 \
PROXY_SYSTEM_API=12025 PROXY_LOAD_BALANCER_TYPE=memory ./srs-proxy
Note: Here we use the memory load balancer, you can switch to
redisif you want to run more than one proxy server.
Then, deploy three origin servers, which connects to the proxy server via port 12025:
./objs/srs -c conf/origin1-for-proxy.conf
./objs/srs -c conf/origin2-for-proxy.conf
./objs/srs -c conf/origin3-for-proxy.conf
Note: The origin servers are independent, so it's recommended to deploy them as Deployments in Kubernetes (K8s).
Now, you're able to publish WebRTC stream via WHIP publisher to the proxy server.
And play the WebRTC stream via WHEP player from proxy server.
Or play the RTMP stream from the proxy server:
ffplay rtmp://localhost/live/livestream
Or play HTTP-FLV stream from the proxy server:
ffplay http://localhost:8080/live/livestream.flv
Or play HLS stream from the proxy server:
ffplay http://localhost:8080/live/livestream.m3u8
You can also use VLC or other players to play the stream in proxy server.
SRT Origin Cluster
To use the SRT origin cluster, you need to deploy the proxy server and the origin server. First, start the proxy server:
env PROXY_RTMP_SERVER=1935 PROXY_HTTP_SERVER=8080 \
PROXY_HTTP_API=1985 PROXY_WEBRTC_SERVER=8000 PROXY_SRT_SERVER=10080 \
PROXY_SYSTEM_API=12025 PROXY_LOAD_BALANCER_TYPE=memory ./srs-proxy
Note: Here we use the memory load balancer, you can switch to
redisif you want to run more than one proxy server.
Then, deploy three origin servers, which connects to the proxy server via port 12025:
./objs/srs -c conf/origin1-for-proxy.conf
./objs/srs -c conf/origin2-for-proxy.conf
./objs/srs -c conf/origin3-for-proxy.conf
Note: The origin servers are independent, so it's recommended to deploy them as Deployments in Kubernetes (K8s).
Now, you're able to publish SRT stream to the proxy server:
ffmpeg -re -i ./doc/source.flv -c copy -pes_payload_size 0 -f mpegts \
'srt://127.0.0.1:10080?streamid=#!::r=live/livestream,m=publish'
And play the SRT stream from the proxy server:
ffplay 'srt://127.0.0.1:10080?streamid=#!::r=live/livestream,m=request'
Or play the RTMP stream from the proxy server:
ffplay rtmp://localhost/live/livestream
Or play HTTP-FLV stream from the proxy server:
ffplay http://localhost:8080/live/livestream.flv
Or play HLS stream from the proxy server:
ffplay http://localhost:8080/live/livestream.m3u8
Or play the WebRTC stream via WHEP player from proxy server.
You can also use VLC or other players to play the stream in proxy server.