nginx相关问题记录

文章目录

    • 1. net::ERR_INCOMPLETE_CHUNKED_ENCODING 200 (OK) 问题解决
    • 2. 升级nacos-client2.0+ 报错 ,nacos-server集群环境时UNAVAILABLE: io exception
    • 3. 下载经过nginx代理后,丢包,下载不全文件,导致下载后无法打开

1. net::ERR_INCOMPLETE_CHUNKED_ENCODING 200 (OK) 问题解决

nginx丢包问题。比如访问某个页面,接口请求都是OK的,但是页面一片空白。看看console答应日志net::ERR_INCOMPLETE_CHUNKED_ENCODING 200 (OK) 问题解决 说是某个js文件没有下载下来。

解决办法:
server节点中配置以下配置,根据具体情况,可以适当调整数值。然后重启nginx。

proxy_buffer_size 1024k; #设置代理服务器(nginx)保存用户头信息的缓冲区大小
proxy_buffers 16 1024k; #proxy_buffers缓冲区,网页平均在32k以下的设置
proxy_busy_buffers_size 2048k; #高负荷下缓冲大小(proxy_buffers*2)
proxy_temp_file_write_size 2048k;#设定缓存文件夹大小,大于这个值,将从upstream服务器传

2. 升级nacos-client2.0+ 报错 ,nacos-server集群环境时UNAVAILABLE: io exception

具体报错如下:

Server check fail, please check server localhost ,port 9848 is available , error ={}
java.util.concurrent.ExecutionException: com.alibaba.nacos.shaded.io.grpc.StatusRuntimeException: UNAVAILABLE: io exception

解决办法:
按照nacos官网的意思就是nginx要多开放出来两个端口,供客户端与服务端,服务端与服务端之间通信。

Nacos2.0版本相比1.X新增了gRPC的通信方式,因此需要增加2个端口。新增端口是在配置的主端口(server.port)基础上,进行一定偏移量自动生成。

端口 与主端口的偏移量 描述
9848 1000 客户端gRPC请求服务端端口,用于客户端向服务端发起连接和请求
9849 1001 服务端gRPC请求服务端端口,用于服务间同步等

使用VIP/nginx请求时,需要配置成TCP转发,不能配置http2转发,否则连接会被nginx断开。

比如集群环境:

nginx代理路径(以后19服务nacos使用这个,账户密码都是之前)
http://172.31.129.19:8848/nacos/index.html
三台nacos: /home/cloud/nacos2.0.3
http://172.31.129.19:1950/nacos/index.html
http://172.31.129.19:1960/nacos/index.html
http://172.31.129.19:1970/nacos/index.html

那么配置应该如下:

stream {
    upstream nacos-server-grpc9848 {
      server 172.31.129.19:2950;
      server 172.31.129.19:2960;
      server 172.31.129.19:2970;
    }

    server {
        listen 9848;
        proxy_pass nacos-server-grpc9848;
    }

    upstream nacos-server-grpc9849 {
      server 172.31.129.19:2951;
      server 172.31.129.19:2961;
      server 172.31.129.19:2971;
    }

    server {
        listen 9849;
        proxy_pass nacos-server-grpc9849;
    }
}

http {
    upstream nacos-server {
      server 172.31.129.19:1950;
      server 172.31.129.19:1960;
      server 172.31.129.19:1970;
    }

    server {
      listen 8848;
      server_name  localhost;
      location /nacos/ {
        proxy_pass http://nacos-server/nacos/;
      }
    }
}

3. 下载经过nginx代理后,丢包,下载不全文件,导致下载后无法打开

问题原因: 可能是nginx配置限制了下载的大小,还有可能是超时等等。

解决办法1: 把下面的必要配置配置到nginx,值大小根据自己的需求配置,重启nginx。

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  120s 120s;

    server {
   #     listen       80;
   #     server_name  localhost;

        client_max_body_size 5000m;
        proxy_max_temp_file_size 5000m;
        proxy_read_timeout 3600s;
        proxy_send_timeout       3600s;

	# 	location / {
	#             return 302 /user-center-portal/;
	#	}
		# ...
	}
}

如果还是解决不了问题,也有可能是nginx访问临时目录没有权限的问题。

解决办法2:

# 授权 ${NGINX_HOME} 为nginx的安装目录,不同的安装方法,可能路径不一样
chmod -R 777 ${NGINX_HOME}/uwsgi_temp/
chmod -R 777 ${NGINX_HOME}/client_body_temp
chmod -R 777 ${NGINX_HOME}/fastcgi_temp
chmod -R 777 ${NGINX_HOME}/proxy_temp
chmod -R 777 ${NGINX_HOME}/scgi_temp
chmod -R 777 ${NGINX_HOME}/uwsgi_temp

你可能感兴趣的:(nginx,nginx,ERR_INCOMPLETE,UNAVAILABLE)