首页 > 解决方案 > nginx 错误 502 上游过早关闭连接,同时从上游读取响应标头

问题描述

几天来,我一直在努力解决这个问题,终于走到了一堵砖墙。当我在浏览器中导航到该页面时,该页面会挂起几秒钟,然后才会出现 502 Bad Gateway Screen。

任何想法任何人???

网址https://sv1.stream05.xyz/link/?driveId=0BwHxX3yoJoeuYzZlNm1jYVhwWWs

根据 NGINX 日志,NGINX 说:

2020/11/04 18:56:31 [error] 14920#14920: *15 upstream prematurely closed connection while reading response header from upstream, client: 141.101.84.6, server: sv1.stream05.xyz, request: "GET /link/?driveId=0BwHxX3yoJoeuYzZlNm1jYVhwWWs HTTP/1.1", upstream: "http://127.0.0.1:6868/link/?driveId=0BwHxX3yoJoeuYzZlNm1jYVhwWWs", host: "sv1.stream05.xyz"

nginx.conf

user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
    worker_connections 768;
    # multi_accept on;
}

http {

    ##
    # Basic Settings
    ##

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;
    # server_tokens off;

    # server_names_hash_bucket_size 64;
    # server_name_in_redirect off;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    ##
    # SSL Settings
    ##

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
    ssl_prefer_server_ciphers on;

    ##
    # Logging Settings
    ##

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    ##
    # Gzip Settings
    ##

    gzip on;
  
  
  
  upstream LoadBalancer {
      server 127.0.0.1:6666;
  }
  upstream ProxyStream {
      server 127.0.0.1:6868;
  }
      
  server {
      listen 80;
      server_name proxy.stream05.xyz;
      
      location / {
          proxy_pass http://LoadBalancer;
          proxy_http_version 1.1;
          proxy_send_timeout   600;
          proxy_read_timeout   600;
          proxy_set_header Upgrade $http_upgrade;
          proxy_set_header Connection 'upgrade';
          proxy_set_header Host $host;
          proxy_cache_bypass $http_upgrade;
      }
  }
      
  server {
      listen 80;
      server_name sv1.stream05.xyz;
      
      location / {
          proxy_pass http://ProxyStream;
          proxy_http_version 1.1;
          proxy_send_timeout   600;
          proxy_read_timeout   600;
          proxy_set_header Upgrade $http_upgrade;
          proxy_set_header Connection 'upgrade';
          proxy_set_header Host $host;
          proxy_cache_bypass $http_upgrade;
      }
  }
  
}

标签: djangonginxwebsocketredisuwsgi

解决方案


推荐阅读