You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

基于Wowza Apple HLS流,如何在播放器获取主m3u8时修复Chunklist URL

Hey there, I’ve helped several developers tackle exactly this problem with Wowza’s HLS streaming service—fixing those chunklist URLs in the master m3u8 every time a player requests it. Let’s walk through the most reliable solutions tailored to your scenario:

方案1:自定义Wowza模块(最灵活)

This is the go-to approach for most use cases because it lets you directly intercept and modify the m3u8 response at the Wowza level, even with dynamic logic.

Step 1: Write the Java Module

Create a simple module that hooks into Wowza’s HTTP request lifecycle to rewrite the chunklist URLs. Here’s a working example:

package com.wowza.wms.plugin.hlsfix;

import com.wowza.wms.http.*;
import com.wowza.wms.vhost.*;

public class ModuleHLSChunkListFix extends ModuleBase {

    public void onHTTPRequest(IVHost vhost, IHTTPRequest req, IHTTPResponse resp) {
        String requestURI = req.getRequestURI();
        
        // Target only master m3u8 requests (adjust the path match to your app/stream)
        if (requestURI.contains("/sportplus4/_definst_/ngrp:plus4_all/") 
            && requestURI.endsWith(".m3u8") 
            && !requestURI.contains("chunklist_")) {
            
            try {
                // Grab the original m3u8 content
                String originalContent = new String(resp.getBody());
                
                // Replace the placeholder URL with your actual public domain/port
                // Example 1: Replace with fixed public URL
                String fixedContent = originalContent.replaceAll("http://\\*:1935", "https://your-public-domain.com:1935");
                
                // Example 2: Use relative paths instead (great if using a reverse proxy)
                // String fixedContent = originalContent.replaceAll("http://\\*:1935/sportplus4/_definst_/ngrp:plus4_all/", "./");
                
                // Update the response with fixed content
                resp.setBody(fixedContent.getBytes());
                resp.setContentLength(fixedContent.length());
            } catch (Exception e) {
                getLogger().error("Failed to fix HLS chunklist URLs: " + e.getMessage());
            }
        }
    }
}

Step 2: Deploy the Module

  1. Compile the code into a JAR file and drop it into your Wowza installation’s lib folder (e.g., /usr/local/WowzaStreamingEngine/lib).
  2. Log into the Wowza Manager, navigate to your sportplus4 application, go to the Modules tab, and add a new module with:
    • Name: HLSChunkListFix
    • Description: Fixes chunklist URLs in master m3u8
    • Class Name: com.wowza.wms.plugin.hlsfix.ModuleHLSChunkListFix
  3. Restart your Wowza service to apply the changes.
方案2: 内置HTTP Rewrite规则(无代码)

If your needs are simple (just static string replacement), you can use Wowza’s built-in rewrite functionality without writing any code.

  1. Open your Wowza conf/VHost.xml file.
  2. Find the <HTTPProviders> section and add this rewrite provider:
<HTTPProvider>
    <BaseClass>com.wowza.wms.http.HTTPProviderRewrite</BaseClass>
    <RequestFilters>*.m3u8</RequestFilters>
    <AuthenticationMethod>none</AuthenticationMethod>
    <Properties>
        <Property>
            <Name>rewriteRules</Name>
            <Value>
                # Replace the placeholder URL in master m3u8
                ^/sportplus4/_definst_/ngrp:plus4_all/(.*\.m3u8)$ replace:http://\*:1935/sportplus4/_definst_/ngrp:plus4_all/ with:https://your-public-domain.com:1935/sportplus4/_definst_/ngrp:plus4_all/
            </Value>
        </Property>
    </Properties>
</HTTPProvider>
  1. Save the file and restart Wowza. This will automatically rewrite all matching chunklist URLs in your master m3u8.
方案3: Reverse Proxy (Nginx)

If you don’t want to modify Wowza’s configuration at all, you can use a reverse proxy like Nginx to intercept and rewrite the m3u8 content.

Here’s a sample Nginx config snippet:

server {
    listen 80;
    server_name your-public-domain.com;

    # Intercept master m3u8 requests and rewrite URLs
    location ~* /sportplus4/_definst_/ngrp:plus4_all/(?<filename>.*\.m3u8)$ {
        proxy_pass http://localhost:1935;
        sub_filter 'http://*:1935' 'https://your-public-domain.com:1935';
        sub_filter_once off; # Replace all occurrences
        sub_filter_types application/vnd.apple.mpegurl; # Target HLS MIME type
    }

    # Pass through all other streaming requests
    location / {
        proxy_pass http://localhost:1935;
    }
}

Quick Testing Tip

After setting up any of these solutions, verify the fix with curl:

curl http://your-wowza-ip:1935/sportplus4/_definst_/ngrp:plus4_all/playlist.m3u8

Check that the chunklist URLs now show your correct public domain instead of the http://*:1935 placeholder.

内容的提问来源于stack exchange,提问作者Rasoul Khalifeh

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 06:18:15