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

2016-07-04 13:05:09 +08:00
 csdreamdong
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"
1564 次点击
所在节点    问与答
4 条回复
sujin190
2016-07-04 13:19:11 +08:00
uwsgi 中又请求了其他网站的接口?或是访问了其他机器的数据库之类的
csdreamdong
2016-07-04 13:26:58 +08:00
@sujin190 木有。 uwsgi 中,,就一个 hello , world 的输出。
sujin190
2016-07-04 13:36:32 +08:00
@csdreamdong 你可以 telnet 连一下端口看看
csdreamdong
2016-07-04 14:39:59 +08:00
@sujin190 我知道哪里错了

iptables -A INPUT -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT
本地地址的访问控制加一条。就可以了。- -

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/290137

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX