|
| 1 | +user nginx; |
| 2 | +worker_processes 4; |
| 3 | +daemon off; |
| 4 | + |
| 5 | +events { |
| 6 | + worker_connections 1024; |
| 7 | +} |
| 8 | + |
| 9 | +http { |
| 10 | + server { |
| 11 | + listen $AVALON_STREAMING_PORT; |
| 12 | + |
| 13 | + vod_mode $VOD_MODE; |
| 14 | + vod_upstream_location /s3; |
| 15 | + vod_last_modified 'Sun, 19 Nov 2000 08:52:00 GMT'; |
| 16 | + vod_last_modified_types *; |
| 17 | + vod_metadata_cache metadata_cache 512m; |
| 18 | + vod_response_cache response_cache 128m; |
| 19 | + vod_hls_absolute_index_urls off; |
| 20 | + vod_hls_absolute_master_urls off; |
| 21 | + |
| 22 | + open_file_cache max=1000 inactive=5m; |
| 23 | + open_file_cache_valid 2m; |
| 24 | + open_file_cache_min_uses 1; |
| 25 | + open_file_cache_errors on; |
| 26 | + |
| 27 | + location /status { |
| 28 | + vod_status; |
| 29 | + } |
| 30 | + |
| 31 | + location /s3/avalon/ { |
| 32 | + internal; |
| 33 | + proxy_pass $AVALON_STREAMING_BUCKET_URL; |
| 34 | + } |
| 35 | + |
| 36 | + location ~ ^/avalon/(?<stream>.+/(?<resource>.+\.(?:m3u8|ts))) { |
| 37 | + vod hls; |
| 38 | + |
| 39 | + gzip on; |
| 40 | + gzip_types application/x-mpegURL; |
| 41 | + |
| 42 | + set $token "$arg_token"; |
| 43 | + add_header X-Stream-Auth-Token "$token"; |
| 44 | + |
| 45 | + sub_filter_types application/vnd.apple.mpegurl; |
| 46 | + sub_filter_once off; |
| 47 | + sub_filter '.ts' ".ts?token=$token"; |
| 48 | + |
| 49 | + auth_request /auth; |
| 50 | + add_header Access-Control-Allow-Headers '*'; |
| 51 | + add_header Access-Control-Expose-Headers 'Server,range,Content-Length,Content-Range'; |
| 52 | + add_header Access-Control-Allow-Methods 'GET, HEAD, OPTIONS'; |
| 53 | + add_header Access-Control-Allow-Origin '*'; |
| 54 | + expires 100d; |
| 55 | + } |
| 56 | + |
| 57 | + location ~ ^/avalon/(.+/.+\.(?:mp3)) { |
| 58 | + set $stream $1; |
| 59 | + |
| 60 | + set $token "$arg_token"; |
| 61 | + add_header X-Stream-Auth-Token "$token"; |
| 62 | + |
| 63 | + gzip on; |
| 64 | + gzip_types audio/mp3; |
| 65 | + |
| 66 | + sub_filter_types audio/mp3; |
| 67 | + sub_filter_once off; |
| 68 | + sub_filter '.mp3' ".mp3?token=$token"; |
| 69 | + |
| 70 | + auth_request /auth; |
| 71 | + |
| 72 | + add_header Access-Control-Allow-Headers '*'; |
| 73 | + add_header Access-Control-Expose-Headers 'Server,range,Content-Length,Content-Range'; |
| 74 | + add_header Access-Control-Allow-Methods 'GET, HEAD, OPTIONS'; |
| 75 | + add_header Access-Control-Allow-Origin "*"; |
| 76 | + expires 100d; |
| 77 | + proxy_pass $AVALON_STREAMING_BUCKET_URL/$stream; |
| 78 | + } |
| 79 | + |
| 80 | + location = /auth { |
| 81 | + resolver 127.0.0.1; |
| 82 | + proxy_pass $AVALON_DOMAIN/authorize.txt?token=$token&name=$stream; |
| 83 | + proxy_pass_request_body off; |
| 84 | + proxy_set_header Content-Length ""; |
| 85 | + proxy_set_header X-Original-URI $request_uri; |
| 86 | + } |
| 87 | + |
| 88 | + location /crossdomain.xml { |
| 89 | + default_type text/xml; |
| 90 | + return 200 '<?xml version="1.0"?> |
| 91 | + <!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd"> |
| 92 | + <cross-domain-policy> |
| 93 | + <site-control permitted-cross-domain-policies="all"/> |
| 94 | + <allow-access-from domain="*" secure="false"/> |
| 95 | + <allow-http-request-headers-from domain="*" headers="*" secure="false"/> |
| 96 | + </cross-domain-policy>'; |
| 97 | + expires 24h; |
| 98 | + } |
| 99 | + } |
| 100 | +} |
0 commit comments