gpt4 book ai didi

mysql - nginx 连接()失败(110 : Connection timed out)

转载 作者:行者123 更新时间:2023-11-29 11:42:02 25 4
gpt4 key购买 nike

我知道,这个问题已经在不同的论坛上被问过多次,但我仍然无法找到解决方案来解决我的问题...情况:我们有 nginx、php-fpm 和 MySQL 堆栈在服务器上。服务器位于 nginx 反向代理后面。问题是,在上游服务器上有干净的错误日志,在反向代理上我收到多条消息

connect() failed (110: Connection timed out) while connecting to >upstream, client: ++++++++++, server: domain.com, request: "GET >/files/imagecache/FrontBullet/blog1/dknasda.jpg HTTP/1.1", upstream: >"http://192.168.158.142:80/files/imagecache/FrontBullet/blog1/dknasda.jpg>", host: "somedomain.com"

由于某种原因,对于不同的资源或文件,此错误每 1-5 分钟就会发生一次。

我在反向代理上的 nginx 配置如下:

    user ++++;
worker_processes 3;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

events {
worker_connections 1024;
use epoll;
}

http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 60s; #keeps the connection open with the client; MS default is 60.
types_hash_max_size 2048;

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

gzip on;
gzip_http_version 1.1;
gzip_vary on;
gzip_comp_level 6;
gzip_proxied any;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript text/x-js;
gzip_buffers 16 8k;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";

upstream main_upstream {

server 192.168.158.142:80 max_fails=3 fail_timeout=60s; # New Server. Sent to 192.168.90
# server 192.168.158.143:80; # HSB
keepalive 32;
}

server {
listen 80 default_server;
listen [::]:80 default_server;
server_name domain.com;

location / {
proxy_buffers 32 32k;
proxy_buffer_size 64k;
proxy_pass http://main_upstream;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-By $server_addr:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_connect_timeout 600s;
proxy_send_timeout 600s;
proxy_read_timeout 600s;
send_timeout 600s;
proxy_http_version 1.1;
proxy_set_header Connection "";
client_max_body_size 32M;
client_body_buffer_size 512k;
}
error_page 404 /404.html;
location = /40x.html {
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}

知道为什么会发生这种情况吗?我使用的是centos 7.1 abd nginx 1.6.3

提前致谢,托多尔

最佳答案

终于找到原因了,几个小时以来它已经干净了。结果发现有两个重叠的问题。第一个是内核在队列已满后丢弃请求。这是一本关于调整内核 Linux 内核参数的好手册 - https://www.nginx.com/blog/tuning-nginx/

问题出现后,我们将站点迁移到新服务器并使用 DHCP 分配 IP 地址 - 这是一个大错误。大约每隔一小时,dhcp 就会重新启动网络接口(interface)。检查整个系统日志,我注意到网络接口(interface)的 IP 会定期重新分配。这些间隔与日志中的错误爆发一致。所以解决方案是回到静态 IP。

关于mysql - nginx 连接()失败(110 : Connection timed out),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35617448/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com