ngnix挂起请求:上游从上游读取响应标头时未发送有效的HTTP / 1.0标头

时间:2019-07-11 08:01:54

标签: java http nginx

当后端服务返回带有4位状态码(例如8888)的响应时,浏览器请求始终保持待处理状态, Nginx错误日志是: 上游没有发送有效的HTTP / 1.0标头,同时从上游读取响应标头,客户端:100.203.20.332,服务器:gateway.hotels.cn,请求:“ GET / mobile / activity / qrcode HTTP / 2.0”,上游:“ {{3 }}”,主持人:“ gateway.hotels.cn”

,但是3位状态代码(例如888)没有此问题。

无需经过nginx,直接命中后端服务返回4位状态码还是3位码就没有任何问题

nginx.conf文件

http {
    include       mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$http_host"  "$request" '
                        '$status $body_bytes_sent "$http_referer" '
                        '"$http_user_agent" "$http_x_forwarded_for" "$uid_got" "$uid_set" "$cookie_lvsessionid" "$upstream_response_time" "$request_time"';

    access_log  /var/log/nginx/access.log  main;
    sendfile        on;
    keepalive_timeout  300;
    open_file_cache max=65535 inactive=20s;
    server_tokens off;
    server_tag nginx2;
    server_info off;
    client_max_body_size        60m;
    client_header_buffer_size 128k;
    client_header_timeout 60m;
    client_body_timeout 60m;
    proxy_buffer_size          16k;
    proxy_buffers              16 80k;
    proxy_busy_buffers_size    80k;
    proxy_temp_file_write_size 280k;
    fastcgi_intercept_errors on;
    proxy_intercept_errors on;
    proxy_cache_path /var/data/cache levels=1:2 keys_zone=NAME:600m inactive=60m;
    proxy_connect_timeout 2s;
    gzip  on;
    gzip_http_version 1.1;
    gzip_vary on;
    gzip_min_length 1000;
    gzip_proxied any;
    gzip_types  text/css application/x-javascript application/json text/xml application/xml application/xml+rss text/javascript;
    underscores_in_headers on;
    server {
            listen  80;
            server_name gateway.hotels.cn;
            access_log  /var/log/nginx/gateway.access.log main;
            return 301  https://$server_name$request_uri;

            proxy_headers_hash_max_size 51200;
            proxy_headers_hash_bucket_size 6400;
            proxy_set_header Host $http_host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header remote-port $remote_port;

            include /etc/nginx/allow-origin.conf;
    }
    server {
            listen  443 ssl http2;
            server_name gateway.hotels.cn;
            access_log  /var/log/nginx/gateway.access.log main;
            error_log  /var/log/nginx/gateway-error.log;

            proxy_headers_hash_max_size 51200;
            proxy_headers_hash_bucket_size 6400;
            proxy_set_header Host $http_host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header remote-port $remote_port;

            ssl         on;
            ssl_certificate     /etc/nginx/keys/hotels.pem;
            ssl_certificate_key /etc/nginx/keys/hotels.key;

            charset utf-8;
            sendfile on;
            send_timeout 300;
            underscores_in_headers on;
            include /etc/nginx/allow-origin.conf;


            location / {
                proxy_pass http://192.168.0.100:8080/;
            }
    }
}

0 个答案:

没有答案