大网数据广告活动
服务器运维问答

NGINX Reverse Proxy, Config Video(MJPG) Stream to use a single connection to the Backend Server

· 52CE 我爱测

I have a question/problem weather it is possible to configure a NGINX Reverse Proxy so that it does not Proxy every Request of a Video Stream to the Backend Server, instead Opening a Single Connection to get the Video stream and …

问题原文

原帖链接 · Flo · CC BY-SA 3.0

I have a question/problem weather it is possible to configure a NGINX Reverse Proxy so that it does not Proxy every Request of a Video Stream to the Backend Server, instead Opening a Single Connection to get the Video stream and distribute it to the Clients. Right now i use following configuration.

server {                                                                        
      listen 9000 ssl;                                                              
      server_name some.domain www.some.domain;                                        
      error_log /var/log/nginx/error.cam.log;                                       
      access_log /var/log/nginx/access.cam.log;                                     
                                                                                
      ssl on;                                                                         
      ssl_certificate /etc/letsencrypt/live/some.domain/fullchain.pem;        
      ssl_certificate_key /etc/letsencrypt/live/some.domain/privkey.pem;       
                                                                                
      location / {                                                              
                                                                                
        auth_basic "Login";                                       
        auth_basic_user_file /etc/nginx/auth/Somefile;   
        proxy_pass http://XXX.XXX.XXX.XXX:9000/;                                  
        proxy_http_version 1.1;                                                 
        proxy_buffering off;        
                                                                                                                
      }                                                                                                                                                                                                                                
}  

    

Which leads to a new Backend to NGINX Connection with the exact same Video Stream everytime a Client Requests requests that site from the NGINX server. Above Graph shows the Outgoing Network traffic: Green=Nginx Server and Blue=Backend Server. Every Peak means a new client accessing the Video MJPG stream.

So the Problem is i have a verry limited Performance from Backend to the NGINX Proxy because the Backend is a Raspberry Pi which cant deliver more that 30Mbit stable stream. I already experimented with buffering etc. but had no success. Is there any method to use a single Connection to the Backend?

Thanks and Regards from Germany, Flo

已采纳解答

原帖链接 · Yarik Dot · CC BY-SA 3.0

Nginx will always create new proxy connection for incoming connection unless it is cached localy. As MJPG is an infinite loop, it doesn't seem as an option here.

What I would however try is setup a ffmpeg/vlc on the proxy server to consume mjpg stream from rpi. Nginx then can connect to local ffmpeg/vlc to get stream. You will then have only one connection to the backend server.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-07-06)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。