【发布时间】:2016-06-07 15:29:53
【问题描述】:
我知道,这个问题已经在不同的论坛上被问过多次,但我仍然无法找到解决我的问题的解决方案......情况:我们有一个 nginx、php-fpm 和 MySQL 堆栈在服务器上。服务器位于 nginx 反向代理后面。问题是在上游服务器上有干净的错误日志,而在反向代理上我收到了多条消息
connect() 在连接到 >upstream 时失败(110:连接超时),客户端:++++++++++,服务器:domain.com,请求:“GET >/files/imagecache/FrontBullet /blog1/dknasda.jpg HTTP/1.1",上游:>"http://192.168.158.142:80/files/imagecache/FrontBullet/blog1/dknasda.jpg>",主机:"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
提前致谢, 托多尔
【问题讨论】:
-
这不是您的 nginx 问题...很可能是您的上游(Apache?)每隔几分钟就会崩溃并重新启动(或阻塞 nginx ip)
-
上游又是nginx,上游的错误日志一目了然。如果您有任何其他想法或向我指出如何检查它,我将不胜感激。
-
确实,您的上游错误很清楚。它告诉你 nginx 请求了某些东西,而某些东西没有回复给 nginx。这不是 nginx 问题,而是您在上游块中列出的那些 ip 上侦听的任何服务器。你在其他服务器上运行 nginx 吗?
标签: mysql nginx centos reverse-proxy