nginx 不稳定错误“111:提供视频文件时连接被拒绝”

nginx 不稳定错误“111:提供视频文件时连接被拒绝”

我有这台服务器,一台 debian 10 arm64 机器,我在上面托管一个 asp core 3.1 视频流网站。

总的来说,它工作得很好,除了有时在播放视频时,由于某种原因 nginx 会生成很多:

*258 connect() failed (111: Connection refused) while connecting to upstream

提供一些视频文件时。

现在这特别奇怪,因为:

  • 尽管视频已成功加载和播放,但我还是收到此错误记录
  • 有时,我的系统似乎会崩溃 - 大概是由于这种行为(因为当 nginx 服务停止时不会发生这种崩溃) - 并且最终成为完全只读。然后我必须重新启动它才能恢复。

这是我的配置:

server {

    listen 443;
    server_name videocloud.my-domain.com;
    ssl_certificate /etc/letsencrypt/live/videocloud.my-domain.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/videocloud.my-domain.com/privkey.pem; # managed by Certbot

    ssl on;
    ssl_session_cache  builtin:1000  shared:SSL:10m;
    ssl_protocols  TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
    ssl_prefer_server_ciphers on;

    auth_basic            "Restricted Area";
    auth_basic_user_file      /etc/apache2/.htpasswd;

    add_header Access-Control-Expose-Headers Accept-Ranges;
    add_header Access-Control-Allow-Origin *;
    add_header Access-Control-Allow-Origin [http://localhost:5002];
    add_header Access-Control-Expose-Headers Accept-Ranges;
    add_header Access-Control-Expose-Headers Content-Encoding;
    add_header Access-Control-Expose-Headers Content-Length;
    add_header Access-Control-Expose-Headers Content-Range;
    add_header accept_ranges bytes;

    proxy_force_ranges on;

    location / {

      proxy_set_header        Host $host;
      proxy_set_header        X-Real-IP $remote_addr;
      proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header        X-Forwarded-Proto $scheme;

      # Fix the It appears that your reverse proxy set up is broken" error.
      proxy_pass          http://localhost:5002;
      proxy_read_timeout  90;

      proxy_redirect      http://localhost:5002 https://videocloud.my-domain.com;
    }

}

答案1

正如上面评论中所建议的,通过将 localhost 替换为 127.0.0.1 并禁用 ipv6 解决了该问题

相关内容