Nginx不接受字节范围 [英] Nginx is not accepting range of bytes

查看:141
本文介绍了Nginx不接受字节范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Nginx来提供文件系统中的视频.我想启用范围请求.

I am using nginx to serve videos from the file system. I would like to enable range request.

当前,这是我文件的返回结果

Currently this is the result returned for my file

curl -I fileurl
HTTP/1.1 200 OK
Server: nginx
Date: Sat, 29 Mar 2014 06:41:41 GMT
Content-Type: video/mp4
Content-Length: 15603963
Last-Modified: Sat, 04 Jan 2014 15:02:26 GMT
Connection: keep-alive
Keep-Alive: timeout=300
Accept-Ranges: bytes

但是如果我发送 curl --header范围:字节= 0-50" fileurl

But if I send curl --header "Range: bytes=0-50" fileurl

整个文件已下载.

这是nginx配置中的服务器:

This is the server in nginx config:

server {
            listen 80;
            server_name myserver;
            error_log logs/myserver.error.log;
            access_log logs/myserver.access.log;

            root /srv/myserver;

            #add_header Accept-Ranges;
            add_header Accept-Ranges bytes;
    }

我还需要启用其他功能吗?如何允许文件的范围请求?

Do I have to enable anything else? How could I allow range requests for the files?

推荐答案

将以下行添加到我的nginx网站配置中后,我能够获得范围请求工作

I was able to get range requests working after adding the following line to my nginx site config

    proxy_force_ranges on;

您可以在此处

这篇关于Nginx不接受字节范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆