我没有收到ngix的回复
nginx日志
2016/05/23 15:19:49 [错误] 9019#0:* 3上游超时(110:连接超时)从上游读取响应头,客户端:122.171.107.80,服务器:54.169.34.178 ,请求:&#34; GET / HTTP / 1.1&#34;,上游:&#34; uwsgi://127.0.0.1:8000&#34;,主持人:&#34; 54.169.34.178&#34; < / p>
以前我只使用uwsgi服务器,现在我想在前面添加nginx,以便它可以提供静态数据并充当api-gateway。
我正在尝试使用此tutoriall。我能够单独运行uwsgi服务器,当我将它与nginx结合使用时,它无法正常工作。
任何人都可以帮助我吗?
user www-data;
worker_processes 4;
pid /run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
##
# nginx-naxsi config
##
# Uncomment it if you installed nginx-naxsi
##
#include /etc/nginx/naxsi_core.rules;
##
# nginx-passenger config
##
# Uncomment it if you installed nginx-passenger
##
#passenger_root /usr;
#passenger_ruby /usr/bin/ruby;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
#mail {
# # See sample authentication script at:
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen localhost:110;
# protocol pop3;
# proxy on;
# }
#
# server {
# listen localhost:143;
# protocol imap;
# proxy on;
# }
#}
启用位点-/ *。CONF
```
upstream testing {
server 127.0.0.1:8000;
}
server {
listen 80;
server_name 54.169.34.178
charset utf-8;
# max upload size
client_max_body_size 75M; # adjust to taste
location / {
uwsgi_pass testing;
include /home/ubuntu/testDjango/testWeb/uwsgi_params;
}
}
```
答案 0 :(得分:0)
根据您分享的配置和详细信息,您使用的uwsgi服务器绑定到0.0.0.0(因为您可以在此处访问54.169.34.178:8000),而在您的nginx配置中,您将上游设置为127.0 .0.1。这就是为什么nginx无法达到您的应用程序。
我建议您使用以下命令在127.0.0.1运行您的应用程序
uwsgi --http 127.0.0.1:8000 --module testWeb.wsgi
现在尝试从您的浏览器访问http://54.169.34.178/
。
答案 1 :(得分:0)
uwsgi_pass不是http协议,而是uwsgi协议,它接受套接字而不是http
当你进行uwsgi_pass测试时,它需要套接字,所以你需要在套接字模式下运行你的uwsgi并验证它的权限(nginx应该能够读取写入该文件)
如果你想将它保存在port和http,你必须将uwsgi_pass更改为proxy_pass