糖尿病康复,内容丰富有趣,生活中的好帮手!
糖尿病康复 > 【故障】nginx间隙性出现502 错误

【故障】nginx间隙性出现502 错误

时间:2021-09-22 20:47:52

相关推荐

【故障】nginx间隙性出现502 错误

#pid logs/nginx.pid;

events {

worker_connections 1024;

}

http {

include mime.types;

default_type application/octet-stream;

#log_format main '$remote_addr - remoteuser[remote_user [remoteu​ser[time_local] “$request” ’

'$status bodybytessent"body_bytes_sent "bodyb​ytess​ent"http_referer" ’

‘“httpuseragent""http_user_agent" "httpu​sera​gent""http_x_forwarded_for”’;

#access_log logs/access.log main;

sendfile on;

#tcp_nopush on;

#keepalive_timeout 0;

keepalive_timeout 65;

#gzip on;

server {

listen 8091;

server_name localhost;

#charset koi8-r;

#access_log logs/host.access.log main;

location / {

proxy_connect_timeout 300s;

proxy_send_timeout 300s;

proxy_read_timeout 300s;

proxy_set_header Host host:host:host:server_port;

proxy_set_header X-real-ip $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_pass http://192.168.1.61:9199/;

}

error_page 500 502 503 504 /50x.html;

location = /50x.html {

root html;

}

}

在测试环境访问,相同的配置没有问题,但是放到正式环境就会出现间隙性访问502的错误。

[](()问题定位

===================================================================

查看nginx 错误日志。

/08/07 09:29:22 [crit] 12236#11116: *457 connect() to 172.18.44.6:8091 failed (10055: An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full) while connecting to upstream, client: 183.17.229.173, server: localhost, request: “GET / HTTP/1.1”, upstream: “http://172.18.44.6:8091/”, host: “183.207.215.123:8091”

/08/07 09:29:22 [crit] 12236#11116: *458 connect() to 172.18.44.6:8091 failed (10055: An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full) while connecting to upstream, client: 183.17.229.173, server: localhost, request: “GET / HTTP/1.1”, upstream: “http://172.18.44.6:8091/”, host: “183.207.215.123:8091”

/08/07 09:29:22 [crit] 12236#11116: *460 connect() to 172.18.44.6:8091 failed (10055: An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full) while connecting to upstream, client: 183.17.229.173, server: localhost, request: “GET / HTTP/1.1”, upstream: “http://172.18.44.6:8091/”, host: “183.207.215.123:8091”

/08/07 09:29:22 [crit] 12236#11116: *462 connect() to 172.18.44.6:8091 failed (10055: An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full) while connecting to upstream, client: 183.17.229.173, server: localhost, request: “GET / HTTP/1.1”, upstream: “http://172.18.44.6:8091/”, host: “183.207.215.123:8091”

/08/07 09:29:22 [crit] 12236#11116: *464 connect() to 172.18.44.6:8091 failed (10055: An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full) while connecting to upstream, client: 183.17.229.173, server: localhost, request: “GET / HTTP/1.1”, upstream: “http://172.18.44.6:8091/”, host: “183.207.215.123:8091”

/08/07 09:29:22 [crit] 12236#11116: *466 connect() to 172.18.44.6:8091 failed (10055: An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full) while connecting to upstream, client: 183.17.229.173, server: localhost, request: “GET / HTTP/1.1”, upstream: “http://172.18.44.6:8091/”, host: “183.207.215.123:8091”

/08/07 09:29:22 [crit] 12236#11116: *468 connect() to 172.18.44.6:8091 failed (10055: An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full) while connecting to upstream, client: 183.17.229.173, server: localhost, request: “GET / HTTP/1.1”, upstream: “http://172.18.44.6:8091/”, host: “183.207.215.123:8091”

/08/07 09:29:22 [crit] 12236#11116: *470 connect() to 172.18.44.6:8091 failed (10055: An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full) while connecting to upstream, client: 183.17.229.173, server: localhost, request: “GET / HTTP/1.1”, upstream: “http://172.18.44.6:8091/”, host: “183.207.215.123:8091”

/08/07 09:29:22 [crit] 12236#11116: *472 connect() to 172.18.44.6:8091 failed (10055: An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full) while connecting to upstream, client: 183.17.229.173, server: localhost, request: “GET / HTTP/1.1”, upstream: “http://172.18.44.6:8091/”, host: “183.207.215.123:8091”

/08/07 09:29:22 [crit] 12236#11116: *474 connect() to 172.18.44.6:8091 failed (10055: An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full) while connecting to upstream, client: 183.17.229.173, server: localhost, request: “GET / HTTP/1.1”, upstream: “http://172.18.44.6:8091/”, host: “183.207.215.123:8091”

/08/07 09:29:22 [crit] 12236#11116: *476 connect() to 172.18.44.6:8091 failed (10055: An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full) while connecting to upstream, client: 183.17.229.173, server: localhost, request: “GET / HTTP/1.1”, upstream: “http://172.18.44.6:8091/”, host: “183.207.215.123:8091”

/08/07 09:29:22 [crit] 12236#11116: *478 connect() to 172.18.44.6:8091 failed (10055: An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full) while connecting to upstream, client: 183.17.229.173, server: localhost, request: “GET / HTTP/1.1”, upstream: “http://172.18.44.6:8091/”, host: “183.207.215.123:8091”

/08/07 09:29:22 [crit] 12236#11116: *480 connect() to 172.18.44.6:8091 failed (10055: An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full) while connecting to upstream, client: 183.17.229.173, server: localhost, request: “GET / HTTP/1.1”, upstream: “http://172.18.44.6:8091/”, host: “183.207.215.123:8091”

/08/07 09:29:22 [crit] 12236#11116: *482 connect() to 172.18.44.6:8091 failed (10055: An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full) while connecting to upstream, client: 183.17.229.173, server: localhost, request: “GET / HTTP/1.1”, upstream: “http://172.18.44.6:8091/”, host: “183.207.215.123:8091”

/08/07 09:29:22 [crit] 12236#11116: *484 connect() to 172.18.44.6:8091 failed (10055: An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full) while connecting to upstream, client: 183.17.229.173, server: localhost, request: “GET / HTTP/1.1”, upstream: “http://172.18.44.6:8091/”, host: “183.207.215.123:8091”

《一线大厂Java面试题解析+后端开发学习笔记+最新架构讲解视频+实战项目源码讲义》无偿开源 威信搜索公众号【编程进阶路】/08/07 09:29:22 [crit] 12236#11116: *486 connect() to 172.18.44.6:8091 failed (10055: An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full) while connecting to upstream, client: 183.17.229.173, server: localhost, request: “GET / HTTP/1.1”, upstream: “http://172.18.44.6:8091/”, host: “183.207.215.123:8091”

/08/07 09:29:22 [crit] 12236#11116: *488 connect() to 172.18.44.6:8091 failed (10055: An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full) while connecting to upstream, client: 183.17.229.173, server: localhost, request: “GET / HTTP/1.1”, upstream: “http://172.18.44.6:8091/”, host: “183.207.215.123:8091”

/08/07 09:29:22 [crit] 12236#11116: *490 connect() to 172.18.44.6:8091 failed (10055: An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full) while connecting to upstream, client: 183.17.229.173, server: localhost, request: “GET / HTTP/1.1”, upstream: “http://172.18.44.6:8091/”, host: “183.207.215.123:8091”

/08/07 09:29:22 [crit] 12236#11116: *494 connect() to 172.18.44.6:8091 failed (10055: An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full) while connecting to upstream, client: 183.17.229.173, server: localhost, request: “GET / HTTP/1.1”, upstream: “http://172.18.44.6:8091/”, host: “183.207.215.123:8091”

/08/07 09:29:22 [crit] 12236#11116: *495 connect() to 172.18.44.6:8091 failed (10055: An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full) while connecting to upstream, client: 183.17.229.173, server: localhost, request: “GET / HTTP/1.1”, upstream: “http://172.18.44.6:8091/”, host: “183.207.215.123:8091”

/08/07 09:29:22 [crit] 12236#11116: *497 connect() to 172.18.44.6:8091 failed (10055: An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full) while connecting to upstream, client: 183.17.229.173, server: localhost, request: “GET / HTTP/1.1”, upstream: “http://172.18.44.6:8091/”, host: “183.207.215.123:8091”

/08/07 09:29:59 [crit] 12236#11116: *490 connect() to 172.18.44.6:8091 failed (10055: An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full) while connecting to upstream, client: 183.17.229.173, server: localhost, request: “GET / HTTP/1.1”, upstream: “http://172.18.44.6:8091/”, host: “183.207.215.123:8091”

都是报错:

10055: An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full

翻译过来的意思就是:套接字上的操作无法执行,因为系统缺少足够的缓冲区空间或队列已满。

意思是说缓存满了,这个更像是服务器的问题。

网上百度了一圈,也没有找到很好的解决方案。

查看端口也没有很多的等待队列。

netstat -ano |findstr “8091”

但是既然是报这种错,系统缺少足够的缓冲区空间。就先从这个错误入手。

在nginx 中设置代理的缓存。

proxy_buffering on;#开启从后端被代理服务器的响应内容缓冲

proxy_buffer_size 4k;#设置从后端被代理服务器的响应内容缓冲区大小

proxy_buffers8 1M; #设置从被代理的后端服务器取得的响应内容缓冲区的大小和数量

proxy_busy_buffers_size 2M; #高负荷下缓冲大小(proxy_buffers*2)

如果觉得《【故障】nginx间隙性出现502 错误》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。