O
O
on_click2021-05-15 15:15:07
Nginx
on_click, 2021-05-15 15:15:07

Why doesn't nginx sub_filter work?

Greetings!

Here is a link to the vimeo playlist

https://player.vimeo.com/external/549610273.m3u8?s=94f4d1739192ea261e18b5de5be7e670d4153219

This playlist contains child playlists.
#EXTM3U
#EXT-X-INDEPENDENT-SEGMENTS
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio-medium",NAME="audio",AUTOSELECT=YES,DEFAULT=YES,CHANNELS="2",URI="https://192vod-adaptive.akamaized.net/exp=1621094196~acl=%2Fc70bafbf-59f9-45f4-9d51-27fa3ef1081f%2F%2A~hmac=451ab23c222faeea960e389e6291d75c911e962bd241b750cdf248f1697eb20f/c70bafbf-59f9-45f4-9d51-27fa3ef1081f/sep/audio/e78a1360/playlist.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio-high",NAME="audio",AUTOSELECT=YES,DEFAULT=YES,CHANNELS="2",URI="https://192vod-adaptive.akamaized.net/exp=1621094196~acl=%2Fc70bafbf-59f9-45f4-9d51-27fa3ef1081f%2F%2A~hmac=451ab23c222faeea960e389e6291d75c911e962bd241b750cdf248f1697eb20f/c70bafbf-59f9-45f4-9d51-27fa3ef1081f/sep/audio/de394c32/playlist.m3u8"

#EXT-X-STREAM-INF:CLOSED-CAPTIONS=NONE,BANDWIDTH=270189,AVERAGE-BANDWIDTH=247000,RESOLUTION=426x240,FRAME-RATE=30.000,CODECS="avc1.640015,mp4a.40.2",AUDIO="audio-medium"
https://192vod-adaptive.akamaized.net/exp=1621094196~acl=%2Fc70bafbf-59f9-45f4-9d51-27fa3ef1081f%2F%2A~hmac=451ab23c222faeea960e389e6291d75c911e962bd241b750cdf248f1697eb20f/c70bafbf-59f9-45f4-9d51-27fa3ef1081f/sep/video/a04493cb/playlist.m3u8
#EXT-X-STREAM-INF:CLOSED-CAPTIONS=NONE,BANDWIDTH=408491,AVERAGE-BANDWIDTH=364000,RESOLUTION=640x360,FRAME-RATE=30.000,CODECS="avc1.64001E,mp4a.40.2",AUDIO="audio-medium"
https://192vod-adaptive.akamaized.net/exp=1621094196~acl=%2Fc70bafbf-59f9-45f4-9d51-27fa3ef1081f%2F%2A~hmac=451ab23c222faeea960e389e6291d75c911e962bd241b750cdf248f1697eb20f/c70bafbf-59f9-45f4-9d51-27fa3ef1081f/sep/video/e78a1360/playlist.m3u8
...

It is necessary to request both the main playlist and replace links to child ones. I thought that sub_filter would handle this, but when using the config below and requesting this url
http://45.141.76.164:8282/p/player.vimeo.com/external/549610273.m3u8?s=94f4d1739192ea261e18b5de5be7e670d4153219
links to child playlists remain unchanged.
server {
    listen 8282;
    resolver 8.8.8.8;

    location ~* ^/p/(.*)$ {
        proxy_set_header Accept-Encoding "";
        proxy_pass https://$1$is_args$args;
        sub_filter_once off;
        sub_filter_types *;
        sub_filter 'https://' 'http://45.141.76.164:8282/p/';
    }
}

Tried different filter_types: *, application/vnd.apple.mpegurl, application/x-mpegURL - to no avail
Can you please tell me if this can be overcome somehow? In a regular text file on my server, the substitution occurs correctly, but the vimeo playlist cannot be changed. Thank you!

nginx -V 
nginx version: nginx/1.18.0 (Ubuntu)
built with OpenSSL 1.1.1f  31 Mar 2020
TLS SNI support enabled
configure arguments: 
--with-cc-opt='-g -O2 -fdebug-prefix-map=/build/nginx-5J5hor/nginx-1.18.0=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Wdate-time -D_FORTIFY_SOURCE=2' 
--with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fPIC' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --modules-path=/usr/lib/nginx/modules --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi 
--with-debug 
--with-compat 
--with-pcre-jit 
--with-http_ssl_module 
--with-http_stub_status_module 
--with-http_realip_module 
--with-http_auth_request_module 
--with-http_v2_module 
--with-http_dav_module 
--with-http_slice_module 
--with-threads 
--with-http_addition_module 
--with-http_gunzip_module 
--with-http_gzip_static_module 
--with-http_image_filter_module=dynamic 
--with-http_sub_module 
--with-http_xslt_module=dynamic 
--with-stream=dynamic 
--with-stream_ssl_module 
--with-mail=dynamic 
--with-mail_ssl_module

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2021-05-15
@on_click

The server responds with a 302 redirect and you need to add proxy_redirect

proxy_redirect 'https://' 'http://45.141.76.164:8282/p/';

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question