nginx 的配置文件:
server {
listen 80;
server_name 127.0.0.1
charset UTF-8;
access_log /var/log/nginx/myweb_access.log;
error_log /var/log/nginx/myweb_error.log;
client_max_body_size 75M;
location / {
include uwsgi_params;
uwsgi_pass 127.0.0.1:8023;
uwsgi_read_timeout 2;
}
location /static {
expires 30d;
autoindex on;
add_header Cache-Control private;
alias /home/work/JZAssist/collected_static/;
}
}
我的 supervisord 中的 command 是
command=uwsgi --http :8023 --chdir /home/work/xxxx --module xxxx.wsgi
xxxx 是项目名称。 问题是可以通过域名加端口访问,但是直接用域名访问就出现 504 Gateway Time-out 。我重装过 nginx,但看起来好像并不是 nginx 的问题。
1
hcymk2 2017 年 2 月 26 日
uwsgi_read_timeout 好像小了点
|
2
cnZary 2017 年 2 月 26 日
你域名解析到哪个 ip ?
是不是没监听到.... |
3
xyxc0673 OP @linzianplay 就只有一个 ip 。为什么域名加端口就可以访问?
|
5
alect 2017 年 2 月 26 日 via Android
sever name 不应该是写域名么?
|
6
Yourdaye 2017 年 2 月 26 日
https://www.v2ex.com/t/339602#reply19 换 gunicorn
|
9
orzfly 2017 年 2 月 26 日 你的 uwsgi 好像是开了个 8023 的 HTTP 端口,你 nginx 居然尝试用 uswsgi 协议连?
include uwsgi_params; uwsgi_pass 127.0.0.1:8023; uwsgi_read_timeout 2; 把 uwsgi 换成 proxy 吧,你这个需要用 proxy_pass 127.0.0.1:8023; |
10
freestyle 2017 年 2 月 26 日
如果 nginx 配置上写的是 uwsgi_pass 那么 uwsgi 启动的命令行参数应该写成 socket 而不是 http
command=uwsgi --socket :8023 --chdir /home/work/xxxx --module xxxx.wsgi |
12
Lax 2017 年 2 月 26 日 via iPad
不贴日志都能猜出来,服你们!
|
13
est 2017 年 2 月 26 日
server {
listen 80; server_name 127.0.0.1 .... } 这三行的意思可能 LZ 没懂,我帮你翻译一下:只有 http://127.0.0.1:80/ 这种形式的网址才能被这个 server { } 块里的配置匹配到。 如果你配置了个域名,不知道你的 server_name 飞到什么鬼地方去了。 |
15
anonymalias 2017 年 2 月 27 日
@est 你应该好好看看 nignx 文档:“ If a server is the only server for a listen port, then nginx will not test server names at all (and will not build the hash tables for the listen port). However, there is one exception. If a server name is a regular expression with captures, then nginx has to execute the expression to get the captures.”
|
16
est 2017 年 2 月 27 日
@anonymalias 你觉得 LZ 这配置就是你贴文档里所说的 the only server 么。
|
17
AyoCross 2017 年 2 月 27 日
我记得当时我在部署 django+uWSGI+Nginx 的时候也出现过这个问题,但最后是怎么解决的有些忘了。。你看一下官方文档步骤,再重来一遍: http://uwsgi-docs.readthedocs.io/en/latest/tutorials/Django_and_nginx.html
|
18
xingzhi 2017 年 3 月 5 日
这个可以作为面试题,挺好的。
|