q191201771 / lal

🔥 Golang audio/video live streaming lib/client/server. support RTMP, RTSP(RTP/RTCP), HLS, HTTP[S]/WebSocket-FLV/TS, GB28181, H264/H265/AAC/G711/OPUS, relay, cluster, record, HTTP Notify/API/UI. 直播
https://pengrl.com/lal
MIT License
2.82k stars 469 forks source link

nginx 代理 flv 流 电脑外网访问 502 错误 #48

Closed puzzle9 closed 3 years ago

puzzle9 commented 3 years ago

nginx.conf

location /live/ {
    proxy_pass http://127.0.0.1:19302/live/;
}

lal.conf

"httpflv": {
  "enable": true,
  "sub_listen_addr": ":19302",
  "enable_https": false,
  "https_addr": ":4433",
  "https_cert_file": "./conf/cert.pem",
  "https_key_file": "./conf/key.pem",
  "gop_num": 2
},

访问地址

正常 http://127.0.0.1/live/20210323-1-151124.flv

502 仅存在于浏览器中 http://192.168.1.6/live/20210323-1-151124.flv

可是如果是手机端访问 都是正常的

错误日志

2021/03/23 15:48:04 [error] 183771#0: *15926 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 192.168.1.7, server: _, request: "GET /live/20210323-1-151124.flv HTTP/1.1", upstream: "http://127.0.0.1:19302/live/20210323-1-151124.flv", host: "192.168.1.7"
nginx version: nginx/1.18.0
lal version; v0.19.1
Google Chrome: 91.0.4449.6
firefox: 86.0.1
puzzle9 commented 3 years ago

我怀疑是 cookie 的问题 同域下面 有cooke时候会出现502这种情况

puzzle9 commented 3 years ago

cookie 字段是 session

puzzle9 commented 3 years ago

最后 解决了

  location /flv/ {
      proxy_set_header Cookie "";
      proxy_pass http://127.0.0.1:17002/flv/;
  }