V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
csdreamdong
V2EX  ›  问与答

求助一个 nginx+uwsgi+iptables 环境下遇到的问题。

  •  
  •   csdreamdong · 2016-07-04 13:05:09 +08:00 · 1559 次点击
    这是一个创建于 2852 天前的主题,其中的信息可能已经有所发展或是发生改变。
    cat /etc/nginx/conf.d/default.conf
    
    server {
        listen       80;
        server_name  www.xxx.xxx;
        
        charset utf-8;
    
        location /test {
            include uwsgi_params;
            uwsgi_pass 127.0.0.1:3031;
        }
    }
    
    cat /etc/mblog/mblog.ini
    
    [uwsgi]
    socket = 127.0.0.1:3031
    pidfile = /run/mblog.pid
    wsgi-file = /usr/share/web_workspace/wsgi.py 
    logto = /var/log/mblog.log
    enable-threads = true
    callable = app
    processes = 2
    threads = 2
    
    iptables -nL
    
    Chain INPUT (policy DROP)
    target     prot opt source               destination         
    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:10086
    ACCEPT     udp  --  0.0.0.0/0            0.0.0.0/0            udp dpt:53
    ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0           
    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:80
    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:443
    
    Chain FORWARD (policy ACCEPT)
    target     prot opt source               destination         
    
    Chain OUTPUT (policy ACCEPT)
    target     prot opt source               destination         
    
    

    主要的配置和环境就是以上的信息。现在遇到了这个问题: 访问 www.xxx.xxx 后,就一直在等待响应。。最终就是超时。 看了下 nginx 的日志,就是 uwsgi 的超时导致的。。 如果关掉 iptables 后,就可以正常访问了。。 所以是哪一步出问题了??

    nginx 的 errorlog

    2016/07/04 13:06:06 [error] 3689#3689: *1 upstream timed out (110: Connection timed out) while connecting to upstream, client: xxx.xxx.xxx.xxx, server: www.xxx.xxx, request: "GET / HTTP/1.1", upstream: "uwsgi://127.0.0.1:3031", host: "www.xxx.xxx"
    
    4 条回复    2016-07-04 14:39:59 +08:00
    sujin190
        1
    sujin190  
       2016-07-04 13:19:11 +08:00
    uwsgi 中又请求了其他网站的接口?或是访问了其他机器的数据库之类的
    csdreamdong
        2
    csdreamdong  
    OP
       2016-07-04 13:26:58 +08:00
    @sujin190 木有。 uwsgi 中,,就一个 hello , world 的输出。
    sujin190
        3
    sujin190  
       2016-07-04 13:36:32 +08:00
    @csdreamdong 你可以 telnet 连一下端口看看
    csdreamdong
        4
    csdreamdong  
    OP
       2016-07-04 14:39:59 +08:00
    @sujin190 我知道哪里错了

    iptables -A INPUT -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT
    本地地址的访问控制加一条。就可以了。- -
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5436 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 07:06 · PVG 15:06 · LAX 00:06 · JFK 03:06
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.