V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
fesiong
V2EX  ›  Linux

最近我管理的网站老是出现"连接被重置",求助解决办法

  •  
  •   fesiong · 2016-03-14 16:12:15 +08:00 · 20470 次点击
    这是一个创建于 2956 天前的主题,其中的信息可能已经有所发展或是发生改变。

    说明一下,访问 php 文件会出现,访问图片也会出现
    在 Firefox 、 IE 下很明显
    Ctrl+F5 刷新基本上都会出现,导致用户体验非常差
    如:
    http://www.seowhy.com/uploads/course/20160307/64_450_280.jpg
    http://www.seowhy.com/

    23 条回复    2016-03-15 13:31:19 +08:00
    ershisi
        1
    ershisi  
       2016-03-14 17:10:52 +08:00   ❤️ 1
    看看你的 mysql 连接时间最大是多少, nginx 的最大连接时长是多少。
    fesiong
        2
    fesiong  
    OP
       2016-03-14 17:14:49 +08:00
    @ershisi 当访问静态文件的时候也是会出现连接被重置,这个又怎么解释呢? nginx 最长连接是 60 秒
    shiji
        3
    shiji  
       2016-03-14 17:25:39 +08:00   ❤️ 1
    我这里 Chromel 里面现实一部分的资源 ERR_CONTENT_LENGTH_MISMATCH ,也就是说,文件的实际大小和 HTTP 服务器返回的大小数据不一致,比如 http://cdn.seowhy.com/adimages/xiaoniao_20160229_3.gifhttp://www.seowhy.com/uploads/course/20160121/51_450_280.jpg 。你用了反代了吗?

    这个 51_450_280.jpg 服务器返回的大小是 136571 ,实际能下载下来的大小只有 34171 ,图片只能显示上面的一小段。
    Strikeactor
        4
    Strikeactor  
       2016-03-14 17:26:28 +08:00   ❤️ 1
    curl -v 'http://www.seowhy.com/uploads/course/20160307/64_450_280.jpg'
    * Trying 59.46.80.34...
    * Connected to www.seowhy.com (59.46.80.34) port 80 (#0)
    > GET /uploads/course/20160307/64_450_280.jpg HTTP/1.1
    > Host: www.seowhy.com
    > User-Agent: curl/7.43.0
    > Accept: */*
    >
    * Recv failure: Connection reset by peer
    * Closing connection 0
    curl: (56) Recv failure: Connection reset by peer

    刚发完请求就被掐了,感觉是 Nginx 的问题
    ToughGuy
        5
    ToughGuy  
       2016-03-14 17:26:47 +08:00   ❤️ 1
    和 mysql 没关系, nginx 后面的问题都能返回 http 错误码。

    1. 检查服务器防火墙有没有问题
    2. 使用默认 nginx 配置试试
    fesiong
        6
    fesiong  
    OP
       2016-03-14 17:28:49 +08:00
    @shiji 反代是什么?我不懂,那应该是我没有设置
    fesiong
        7
    fesiong  
    OP
       2016-03-14 17:29:24 +08:00
    fesiong
        8
    fesiong  
    OP
       2016-03-14 17:30:04 +08:00
    感谢,我再配置一下 nginx 试一下
    ToughGuy
        9
    ToughGuy  
       2016-03-14 17:34:08 +08:00
    ```
    err=0; for _ in {1..100}; do curl -q --connect-timeout 1 --header 'Host: www.seowhy.com' http://127.0.0.1/uploads/course/20160307/64_450_280.jpg >/dev/null 2>&1 || ((err++)); done; echo $err
    ```

    在服务器上面通过 127.0.0.1 请求资源看会不会出现错误。
    fesiong
        10
    fesiong  
    OP
       2016-03-14 17:34:12 +08:00
    除了访问网页,链接 ssh 、远程 mysql ,也老是被断开,这个又会是什么原因呢?

    @ToughGuy
    @Strikeactor
    @shiji
    fesiong
        11
    fesiong  
    OP
       2016-03-14 17:36:07 +08:00
    @ToughGuy 执行完了之后,输出 0 。
    Strikeactor
        12
    Strikeactor  
       2016-03-14 17:39:28 +08:00
    @fesiong 所有连接都时不时断?防火墙关了先,还这样的话你打电话问问机房是不是在维护吧。。
    ToughGuy
        13
    ToughGuy  
       2016-03-14 17:41:32 +08:00   ❤️ 1
    @fesiong

    这样的话可以排除掉 nginx 问题了。

    1. 检查防火墙
    iptables -L -n -v
    dmesg

    2. 有没有动过服务器默认网络相关的内核参数
    /etc/sysctl.conf

    3. 检查网卡 errors, dropped, frame 这几个项目值是不是 0 , 不为 0 说明网卡或者网线可能存在问题。

    ifconfig
    fesiong
        14
    fesiong  
    OP
       2016-03-14 17:57:04 +08:00
    @ToughGuy
    3 ,几个字段都是 0 ;
    2 ,我没动过内核,不清楚服务商那边;
    1 ,防火墙打印出来一堆,太长,看不懂。

    明天再找服务商沟通一下
    zaishanfeng
        15
    zaishanfeng  
       2016-03-14 18:04:17 +08:00 via Android
    可能是 isp 的问题 我们伟大的墙就经常玩这招
    ershisi
        16
    ershisi  
       2016-03-14 20:30:14 +08:00
    [除了访问网页,链接 ssh 、远程 mysql ,也老是被断开,这个又会是什么原因呢] 网关问题吧。
    blackboar
        17
    blackboar  
       2016-03-14 22:00:47 +08:00
    让托管商排查下机房防火墙,可能有 web 防护。
    techmoe
        18
    techmoe  
       2016-03-15 05:54:03 +08:00 via Android
    如果服务器在国外可能是被墙了
    fesiong
        19
    fesiong  
    OP
       2016-03-15 09:07:41 +08:00
    @techmoe 服务器是在辽宁的,应该没墙
    kungfuchicken
        20
    kungfuchicken  
       2016-03-15 10:09:32 +08:00
    MTR 测试显示 202.97.81.234 中国辽宁沈阳 电信 主干掉包率高达 40%,应该是这个引起的
    kungfuchicken
        21
    kungfuchicken  
       2016-03-15 10:10:14 +08:00
    |------------------------------------------------------------------------------------------|
    | WinMTR statistics |
    | Host - % | Sent | Recv | Best | Avrg | Wrst | Last |
    |------------------------------------------------|------|------|------|------|------|------|
    | 192.168.24.129 - 0 | 125 | 125 | 3 | 12 | 617 | 4 |
    | No response from host - 100 | 24 | 0 | 0 | 0 | 0 | 0 |
    |129.155.183.61.dial.wh.hb.dynamic.163data.com.cn - 0 | 125 | 125 | 0 | 2 | 113 | 1 |
    | **** - 0 | 125 | 125 | 1 | 3 | 5 | 1 |
    | **** - 0 | 125 | 125 | 1 | 3 | 5 | 2 |
    | 202.97.36.202 - 0 | 125 | 125 | 21 | 22 | 26 | 21 |
    | 202.97.81.234 - 38 | 48 | 30 | 0 | 41 | 43 | 41 |
    | No response from host - 100 | 24 | 0 | 0 | 0 | 0 | 0 |
    | 219.148.224.50 - 2 | 117 | 115 | 43 | 46 | 55 | 44 |
    | 219.148.224.66 - 0 | 125 | 125 | 40 | 40 | 48 | 40 |
    |126.23.44.59.broad.sy.ln.dynamic.163data.com.cn - 0 | 125 | 125 | 47 | 47 | 47 | 47 |
    | No response from host - 100 | 24 | 0 | 0 | 0 | 0 | 0 |
    | No response from host - 100 | 24 | 0 | 0 | 0 | 0 | 0 |
    | No response from host - 100 | 24 | 0 | 0 | 0 | 0 | 0 |
    | No response from host - 100 | 24 | 0 | 0 | 0 | 0 | 0 |
    | No response from host - 100 | 24 | 0 | 0 | 0 | 0 | 0 |
    | No response from host - 100 | 24 | 0 | 0 | 0 | 0 | 0 |
    | No response from host - 100 | 24 | 0 | 0 | 0 | 0 | 0 |
    | No response from host - 100 | 24 | 0 | 0 | 0 | 0 | 0 |
    | No response from host - 100 | 24 | 0 | 0 | 0 | 0 | 0 |
    | No response from host - 100 | 24 | 0 | 0 | 0 | 0 | 0 |
    | No response from host - 100 | 24 | 0 | 0 | 0 | 0 | 0 |
    | No response from host - 100 | 24 | 0 | 0 | 0 | 0 | 0 |
    | No response from host - 100 | 24 | 0 | 0 | 0 | 0 | 0 |
    | No response from host - 100 | 24 | 0 | 0 | 0 | 0 | 0 |
    | No response from host - 100 | 24 | 0 | 0 | 0 | 0 | 0 |
    | No response from host - 100 | 24 | 0 | 0 | 0 | 0 | 0 |
    | No response from host - 100 | 24 | 0 | 0 | 0 | 0 | 0 |
    | No response from host - 100 | 24 | 0 | 0 | 0 | 0 | 0 |
    | No response from host - 100 | 24 | 0 | 0 | 0 | 0 | 0 |
    |________________________________________________|______|______|______|______|______|______|
    WinMTR v0.92 GPL V2 by Appnor MSP - Fully Managed Hosting & Cloud Provider
    realpg
        22
    realpg  
       2016-03-15 10:44:46 +08:00
    看了下 IP ,只能说楼主你换个有网管的服务商吧,哪怕网吧网管级别的……
    ToughGuy
        23
    ToughGuy  
       2016-03-15 13:31:19 +08:00
    @fesiong

    嗯 那只能找机房解决。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5817 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 06:23 · PVG 14:23 · LAX 23:23 · JFK 02:23
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.