环境: win10 64位 ,nginx1.8.3,tomcat7
背景: 搭建开发环境

问题: 在win10上安装了nginx做动静分离和负载均衡。localhost:8080可以正常访问项目,

但是通过nginx访问80端口,只能访问磁盘上的静态文件,转发到tomcat的请求却始终timeout.


配置文件

worker_processes  2;events {worker_connections  1024;
}http {include       mime.types;default_type  application/octet-stream;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  logs/access.log  main;sendfile        on;#tcp_nopush     on;#keepalive_timeout  0;keepalive_timeout  65;#gzip  on;#设定负载均衡的服务器列表,动态服务器tomcatupstream localhost_up {server localhost:8080;}server {listen       80;server_name  localhost;location ~* ^/static/ueditor/upload/(.+\.(?:js|css|gif|jpg|jpeg|png|html|xls|xlsx|pdf))$ {alias D:/static/ueditor/upload/$1;}location  /ueditor/  {proxy_pass http://localhost_up;proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Real-Request-URI $uri;proxy_set_header X-Real-URL $scheme://$host$request_uri;}}
}

error.log日志文件log

2016/10/10 08:34:33 [notice] 9984#12548: signal process started
2016/10/10 08:35:51 [error] 4312#4752: *312 upstream timed out (10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond) while connecting to upstream, client: 127.0.0.1, server: localhost, request: "GET /ueditor/pages/ueditor/editor.html/ HTTP/1.1", upstream: "http://[::1]:8080/ueditor/pages/ueditor/editor.html/", host: "localhost"
2016/10/10 08:47:47 [error] 4312#4752: *327 upstream timed out (10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond) while connecting to upstream, client: 127.0.0.1, server: localhost, request: "GET /ueditor/pages/ueditor/editor.html/ HTTP/1.1", upstream: "http://[::1]:8080/ueditor/pages/ueditor/editor.html/", host: "localhost"

网上很多说配上连接超时就可以解决问题, 但是并没有解决我的问题,下面是配置,大家可以试试。

proxy_connect_timeout 1;
proxy_send_timeout 30;
proxy_read_timeout 60; 

我个人觉得这并不是连接超时的问题。

我们从ip这个角度出发。ping 一下localhost,打开cmd命令窗。

是不是觉得哪里有点不对劲,以前ping,返回结果都是很长类似这样  来自xxx.xxx.xxx.xxx的恢复:时间<2ms。现在确实【::1】。

没错,问题就出现在这里,win10默认的是ipv6的解析,而ipv6默认解析到【::1】而不是127.0.0.1。所以我们nginx配置文件里面是连接不到本地的tomcat,一直处于timeout的状态,这只是一个猜测,下面我们来印证一下,看看是不是这么回事。

去注册表修改ip4的优先级。

打开运行窗口,输入【regedit】

在这个路径下面:HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\tcpip6\Parameters,新建【DWORD(32位)值(D)】,一定要新建这个哦,否则无效。

然后窗口右侧会出现你新建的键值,如图

选中【新值#1】F2修改键值名称为:DisabledComponents,如下图

选中,右键,修改如下图。然后点击确定。

重启电脑,我们再来ping一下localhost.

现在看上去是不是顺眼很多了,没错我们已经将localhost默认解析到127.0.0.1这样我们在来通过nginx访问。

最终证实不会出现  upstream timed out (10060: A connection。。。。这个问题!

希望对大家有帮助。

win10 tomcat nginx upstream timed out 10060相关推荐

  1. Nginx报upstream timed out错误

    前两天给客户部署生产环境,客户提供的是windows服务,我们的系统是前后台分离的,前台使用nginx容器,我按正常思路部署好服务后,前台页面正常显示,但是前台连接后台时,时好时坏,经常连不到后台服务 ...

  2. Nginx报错:upstream timed out (110: Connection timed out)和client intended to send too large body【转】...

    nginx日志报错 2018/01/26 16:36:49 [error] 23327#0: *54953 upstream timed out (110: Connection timed out) ...

  3. nginx 报错 upstream timed out (110: Connection timed out)解决方案

    nginx 报错 upstream timed out (110: Connection timed out)解决方案 参考文章: (1)nginx 报错 upstream timed out (11 ...

  4. nginx响应超时upstream timed out (110: Connection timed out) while reading response header from upstream

    问题描述 解决方法 提高nginx网络吞吐量buffers优化指令说明 nginx代理超时配置 nginx缓存区大小设置 问题描述 后台server服务响应时间正常,但是请求没有打到服务器,在ngin ...

  5. 记一次网站故障排查过程(nginx 504状态码、 upstream timed out (110: Connection timed out)以及jbd2引起IO高

    一.问题描述 客户侧反馈无法正常访问系统,页面转圈,时好时坏,访问不稳定. 二.系统环境: 机器环境:UOS . nginx .php(对接其他服务器kingbase .钉钉.redis .KF) E ...

  6. Nginx upstream (一) 整体流程分析

    Nginx访问上游服务器的流程大致分以下几个阶段:启动upstream.连接上游服务器.向上游发送请求.接收上游响应(包头/包体).结束请求.本篇主要从代码流程的角度,梳理一下upstream的整个的 ...

  7. tomcat+nginx+redis实现均衡负载、session共享(一)

    在项目运营时,我们都会遇到一个问题,项目需要更新时,我们可能需先暂时关闭下服务器来更新.但这可能会出现一些状况: 1.用户还在操作,被强迫终止了(我们可以看日志等没人操作的时候更新,但总可能会有万一) ...

  8. Redis+Tomcat+Nginx集群实现Session共享,Tomcat Session共享

    转载自  Redis+Tomcat+Nginx集群实现Session共享,Tomcat Session共享 一.Session共享使用tomcat-cluster-redis-session-mana ...

  9. tomcat+nginx+redis实现均衡负载、session共享

    在项目运营时,我们都会遇到一个问题,项目需要更新时,我们可能需先暂时关闭下服务器来更新.但这可能会出现一些状况: 1.用户还在操作,被强迫终止了(我们可以看日志等没人操作的时候更新,但总可能会有万一) ...

最新文章

  1. hdu1428 spfa+记忆化搜索
  2. caxa电子图板2018中文版
  3. window系统下C语言找不到fork()函数
  4. 使用ActiveMQ –具有故障转移协议的“主/从”配置
  5. lftp linux,linux下使用 lftp
  6. python的高阶函数
  7. 快来看,大数据两地三中心的容灾也可以如此省心!
  8. pandas 在某个列表中的值 筛选列_Pandas学习笔记(二)
  9. 面向对象(程序员最呆的地方,一切皆是对象)
  10. spring boot RESTFul API拦截 以及Filter和interceptor 、Aspect区别
  11. xpath返回结果是否有值_【自学C#】|| 笔记 41 DataReader:读取查询结果
  12. LoadRunner录制app脚本详解
  13. 大疆2019校招FPGA笔试总结
  14. 基于组态王和三菱PLC的modbus仿真(七)——RS指令
  15. php框架 猪婆,猪婆塘_三湖文学社_新高淳论坛 - Powered by Discuz!
  16. python对市场营销-python数据分析:商品数据化运营(上)——知识点
  17. java局域网通信_java局域网通信
  18. 电源适配器的作用有哪些
  19. 计算机配置好坏怎么看,查看电脑配置状况好坏的技巧
  20. 5G NR 随机接入RACH流程(3)-- Msg1之选择正确的PRACH时频资源

热门文章

  1. 日语常见自、他动词对照表
  2. python程序设计杨柏林pdf_Python程序设计教程 PDF 下载
  3. windows系统下启动redis命令
  4. 学ruby用什么软件实现编程?Ruby的最佳IDE或文本编辑器
  5. 快速启动Keycloak
  6. 【面经_智力情景题_(个人总结】
  7. android 夜间模式功能,Android实现夜间模式切换功能实现代码
  8. Android增加系统白名单,防止重要应用低内存时被误杀
  9. 【Redis持久化】:Redis持久化的意义
  10. Spring 线程池使用