Fix HLS browser in prod e stabilizza broadcast RTMP su iOS.

Il proxy Rails gestisce il redirect MediaMTX su /live/match_* e riscrive le playlist; edge nginx reindirizza /live/ sotto /hls/. Su iOS, SessionBuilder HaishinKit, pipeline mixer corretta e refresh token.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Emiliano Frascaro
2026-06-19 18:48:29 +02:00
parent ed0f913138
commit a303a94671
16 changed files with 1092 additions and 319 deletions

View File

@@ -13,7 +13,8 @@ Rails.application.configure do
config.ssl_options = {
redirect: {
exclude: ->(request) {
request.path == "/up" || request.path == "/up/deep" || request.path == "/cable" || request.path.start_with?("/hls/")
request.path == "/up" || request.path == "/up/deep" || request.path == "/cable" ||
request.path.start_with?("/hls/") || request.path.match?(%r{\A/live/match_[0-9a-f-]{36}/}i)
}
}
}
@@ -34,7 +35,8 @@ Rails.application.configure do
config.host_authorization = {
exclude: ->(request) {
request.path == "/up" || request.path == "/up/deep" || request.path.start_with?("/cable") || request.path.start_with?("/hls/")
request.path == "/up" || request.path == "/up/deep" || request.path.start_with?("/cable") ||
request.path.start_with?("/hls/") || request.path.match?(%r{\A/live/match_[0-9a-f-]{36}/}i)
}
}

View File

@@ -109,6 +109,16 @@ Rails.application.routes.draw do
end
get "hls/*path", to: "hls_proxy#show", format: false, constraints: { path: /.+/ }
# MediaMTX HLS cookie redirect → /live/match_{uuid}/… (edge o browser dopo 302).
get "live/match_:session_id",
to: "hls_proxy#live_match",
format: false,
constraints: { session_id: /[0-9a-f-]{36}/i },
defaults: { segments: "index.m3u8" }
get "live/match_:session_id/*segments",
to: "hls_proxy#live_match",
format: false,
constraints: { session_id: /[0-9a-f-]{36}/i, segments: /.+/ }
get "live", to: "public/live#index", as: :public_live_index
get "live/:id", to: "public/live#show", as: :public_live