kaltura / nginx-vod-module

NGINX-based MP4 Repackager
GNU Affero General Public License v3.0
2k stars 439 forks source link

Need help about remote mode #1457

Open lystormenvoy opened 1 year ago

lystormenvoy commented 1 year ago

I am testing remote mode my config in nginx:

location ^~ /group {
    add_header 'Access-Control-Allow-Origin' * always;
    add_header 'Access-Control-Allow-Credentials' 'true';
    #add_header 'Access-Control-Allow-Headers' authorization,Authorization,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,token;
    include conf.d/options.conf;
    proxy_pass http://dfs_server;
    proxy_buffering off;
    add_header ava-path 'fdfs';
}

location /vod2 {
    add_header backendIP $upstream_addr;
    add_header backendCode $upstream_status;
    include conf.d/proxy.conf;
    include conf.d/options.conf;
    include conf.d/cache_lite.conf;
    proxy_pass http://gateway_server/vod_back;
    proxy_set_header Forwarded_Path $http_forwarded_path;
#    include conf.d/location_webservice.conf;
    add_header ava-path 'cache-hls';
    proxy_cache_valid 200 302 206 20m;
}

location /vod_back/
                {
                        vod hls;
                        #vod dash;
                        #vod_mode local;
                        vod_mode remote;
                        vod_segment_duration 8000;
                        vod_align_segments_to_key_frames on;
                        vod_hls_container_format fmp4;
                        vod_hls_force_unmuxed_segments on;
                        vod_hls_absolute_index_urls off;
                        vod_hls_output_iframes_playlist off;
                        vod_manifest_segment_durations_mode accurate;
#                       vod_multi_uri_suffix .mp4;
                        include conf.d/options.conf;
                        add_header 'Access-Control-Allow-Origin' '*';
                        add_header 'Access-Control-Allow-Credentials' 'true';

                        vod_metadata_cache metadata_cache 1024m;
                        vod_response_cache response_cache 128m;
                        vod_cache_buffer_size 512k;
                        vod_mapping_cache mapping_cache 5m;

                        #alias /usr/local/openresty/nginx/QP_HLS/;
                        vod_upstream_location /group1;

                        open_file_cache          max=2000 inactive=10m;
                        open_file_cache_valid    4m;
                        open_file_cache_min_uses 1;
                        open_file_cache_errors   on;
                        aio on;
                }

When I visited https://gx.avawe.cn/vod_back/group1/M0/00/53/wKgl4GSBUCyEACibAAAAAIsTOIM935.mp4/index.m3u8 it seems to proxy to /group1/vod_back/group1/M0/00/53/wKgl4GSBUCyEACibAAAAAIsTOIM935.mp4 Because I fount the access log print : 192.168.37.224 - - [03/Aug/2023:13:59:27 +0800] "GET /group1/vod_back/group1/M0/00/53/wKgl4GSBUCyEACibAAAAAIsTOIM935.mp4 HTTP/1.0" 400 150 "-" "VLC/3.0.18 LibVLC/3.0.18"

When I visited https://gx.avawe.cn/vod_back/M0/00/53/wKgl4GSBUCyEACibAAAAAIsTOIM935.mp4/index.m3u8 it seems to proxy to /group1/vod_back/M0/00/53/wKgl4GSBUCyEACibAAAAAIsTOIM935.mp4 Because I fount the access log print : 192.168.37.224 - - [03/Aug/2023:13:59:27 +0800] "GET /group1/vod_back/M0/00/53/wKgl4GSBUCyEACibAAAAAIsTOIM935.mp4 HTTP/1.0" 400 150 "-" "VLC/3.0.18 LibVLC/3.0.18"

So is there any way make it proxy to /group1/M0/00/53/wKgl4GSBUCyEACibAAAAAIsTOIM935.mp4

erankor commented 1 year ago

No, but what you can do is edit the proxied URL in location ^~ /group. For example, something like this -

location ~ /group([^/]+)/vod_back/(.*) {
    proxy_pass http://dfs_server/group$1/$2;
}
lystormenvoy commented 1 year ago

ok,I will evaluate it