[英](nginx + uwsgi + django). nginx server is not allowing the request to hit the uwsgi server
我沒有收到ngix的任何回復
Nginx日志
2016/05/23 15:19:49 [錯誤] 9019#0:* 3從上游讀取響應頭時,上游超時(110:連接超時),客戶端:122.171.107.80,服務器:54.169.34.178,請求: “ GET / HTTP / 1.1”,上游:“ uwsgi://127.0.0.1:8000”,主機:“ 54.169.34.178”
以前我只使用uwsgi服務器,現在我想在前端添加nginx,以便它可以提供靜態數據並充當api-gateway。
我正在嘗試使用本教程 。 我能夠分別運行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;
# }
#}
啟用了sites / *。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;
}
}
```
根據您共享的配置和詳細信息,就像使用uwsgi服務器一樣,該服務器已綁定到0.0.0.0(因為您可以在此處訪問它54.169.34.178:8000),而在nginx配置中則將上游設置為127.0.0.1。 這就是nginx無法訪問您的應用程序的原因。
我建議您使用以下命令uwsgi --http 127.0.0.1:8000 --module testWeb.wsgi
在127.0.0.1上運行您的應用程序
現在嘗試從瀏覽器訪問http://54.169.34.178/
。
uwsgi_pass不是http協議,而是接受套接字而不是http的uwsgi協議
當您執行uwsgi_pass測試時,它需要套接字,因此您需要在套接字模式下運行uwsgi並驗證其權限(nginx應該能夠對該文件進行讀寫操作)
如果您想將其保留在端口和http,則必須將uwsgi_pass更改為proxy_pass
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.