首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >nginx tomcat7错误:-“recv()失败(104:从上游读取响应标头时连接重置)”

nginx tomcat7错误:-“recv()失败(104:从上游读取响应标头时连接重置)”
EN

Stack Overflow用户
提问于 2017-09-12 18:28:04
回答 1查看 4.1K关注 0票数 1

我在我的nginx日志中得到两种类型的错误。

错误-1 connect()失败(110:连接超时)而连接到上游 Error-2 recv()失败(104:从上游读取响应标头时连接重置)

所以我的上游是前面的Tomcat7和Nginx。

我不明白为什么我会犯这个错误。因为,当我在8080端口上点击tomcat7时,它的工作负载很重。但是,在Nginx上(在端口80上运行)进行高负载时,代理对tomcat7的请求就会失败,出现以下两个错误。我能得到的所有答案都是关于PHP的,但我没有使用它。我不知道该怎么修理。

编辑:-

代码语言:javascript
复制
user www-data;
worker_processes auto;
worker_rlimit_nofile 10000;
pid /run/nginx.pid;

events {

	worker_connections 2000;
	multi_accept on;
	use epoll;
}
http {

	open_file_cache max=200000 inactive=20s;
	open_file_cache_valid 30s;
	open_file_cache_min_uses 2;
	open_file_cache_errors on;
	reset_timedout_connection on;
	client_body_timeout 200s; # Use 5s for high-traffic sites
	client_header_timeout 200s;

	##
	# Basic Settings
	##

	sendfile on;
	tcp_nopush on;
	tcp_nodelay on;
	keepalive_timeout 9000;
	keepalive_requests 100000;
	types_hash_max_size 2048;
	proxy_connect_timeout 16000s;
	proxy_send_timeout 16000s;
	proxy_read_timeout 16000s;
	send_timeout 16000s;

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

	access_log /var/log/nginx/access.log;
	error_log /var/log/nginx/error.log;

	##
	# Gzip Settings
	##

	gzip on;
	gzip_disable "msie6";

	##
	# Virtual Host Configs
	##
	include /etc/nginx/conf.d/*.conf;
	include /etc/nginx/sites-enabled/*;
}




# configuration file /etc/nginx/sites-enabled/default:
upstream _tomcat-stream-beta {

	server 127.0.0.1:8080;
	keepalive 500000;
}
server {

	#recursive_error_pages on;
	listen 80 default_server;
	server_name 127.0.0.1;
	#docshare Root WebSite
	root /usr/share/nginx/www/;
	#  error_page 500 502 503 504 =200 /api/testing/errorHandle?headers=$http_attributes;
	error_log /var/log/nginx/stream.error.log;
	access_log /var/log/nginx/stream.access.log;
	client_body_in_file_only on;
	proxy_set_header X-Real-IP $remote_addr;
	proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
	proxy_set_header Host $http_host;
	large_client_header_buffers 8 64k;

	location ~ /.well-known {

		allow all;
	}

	location @tomcat-stream-beta {

		proxy_pass http://_tomcat-stream-beta;
	}
	location ^~ / {

		proxy_pass http://_tomcat-stream-beta;
		proxy_read_timeout 600000s;
		proxy_connect_timeout 600000s;
		proxy_send_timeout 600000s;
		proxy_ignore_client_abort on;
	}
}

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-10-26 06:19:38

我最后使用了以下配置:

  1. 我们必须加快我们的内部代码,即代码执行时间。现在,每一个请求所需的时间都不到50 ms。
  2. Nginx的配置是:-

代码语言:javascript
复制
user www-data;
worker_processes auto;
worker_rlimit_nofile 10000;
pid /run/nginx.pid;

events {
    worker_connections 2000;
    multi_accept on;
    use epoll;
}

http {
    open_file_cache max=200000 inactive=20s;
    open_file_cache_valid 30s;
    open_file_cache_min_uses 2;
    open_file_cache_errors on;
    reset_timedout_connection on;
    client_body_timeout 200s; # Use 5s for high-traffic sites
    client_header_timeout 200s;

    ##
    # Basic Settings
    ##
    sendfile on;

    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 900;
    keepalive_requests 10000;
    types_hash_max_size 2048;
    #proxy_buffering off;
    proxy_connect_timeout 1600;
    proxy_send_timeout 1600;
    proxy_read_timeout 1600;
    send_timeout 1600;
    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    access_log /var/log/nginx/stream.access.log;
    error_log /var/log/nginx/stream.error.log;

    gzip on;
    gzip_disable "msie6";

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46183214

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档