uwsgi不提供任何请求

uwsgi不提供任何请求

本文介绍了nginx / uwsgi不提供任何请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有nginx,uwsgi,django stack。使用nginx的https服务,但我试图禁用它。



这是我的nginx配置文件:



nginx.conf:

  events {
worker_connections 768;
#multi_accept on;
}

http {

proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;

##
#基本设置
##

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;

##
#记录设置
##

access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

##
#Gzip设置
##

gzip on;
gzip_disablemsie6;

#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
##
#如果您安装了nginx-naxsi
##

#include /etc/nginx/naxsi_core.rules;

##
#nginx-passenger config
##
#如果您安装了nginx-passenger
##

#passenger_root / usr;
#passenger_ruby / usr / bin / ruby​​;

##
#虚拟主机配置
##

include /etc/nginx/conf.d/*.conf;
包含/ etc / nginx / sites-enabled / *;
}

site-available / mysite.com:

 上游django {
服务器127.0.0.1:44000;
}

server {
listen 80 default;
server_name www.mysite.com mysite.com;


charset utf-8;
access_log /var/log/nginx/mysite_access.log;
error_log /var/log/nginx/mysite_error.log;

location / static / {
root / opt / myapp / myapp /;
index index.html index.htm;
}

位置/ {
uwsgi_pass django;
包括uwsgi_params;
}
}

当我运行它与uwsgi我得到这个错误:

  django.core.exceptions.SuspiciousOperation:无效的HTTP_HOST标头(您可能需要设置ALLOWED_HOSTS):www.mysite.com 
[pid:12865 | app:0 | req:1/2] 84.94.36.146(){36 vars in 571 bytes} [Mon May 26 07:12:55 2014] GET /favicon.ico =>在457毫秒(HTTP / 1.1 500)中生成0个字节0个字节中的0个标题(0个内核上的0个开关)

我将www.mysite.com放在settings.py的ALLOWED_HOSTS部分,并没有帮助。
这些是我在settings.py中添加的行:

  ALLOWED_HOSTS = [
'.mysite。 com',#允许域和子域
'.mysite.com',#也允许FQDN和子域
]

当我运行runserver我得到这个错误:

  [26 / 2014 06:53:09]代码400,消息错误请求语法('\x00; \x02\x00\x0c\x00QUERY_STRING\x00\x00\x0e\x00REQUEST_METHOD\x03\x00GET \x0c\x00CONTENT_TYPE\x00\x00\x0e\x00CONTENT_LENGTH\x00\x00\x0b\x00REQUEST_URI\x0c\x00 / favicon.ico\t\x00PATH_INFO\x0c\\ \\x00 / favicon.ico\r\x00DOCUMENT_ROOT\x0f\x00的/ etc / nginx的/ html\x0f\x00SERVER_PROTOCOL\x08\x00HTTP / 1.1\x0b\x00REMOTE_ADDR\x0c\x0084 .94.36.146\x0b\x00REMOTE_PORT\x05\x0051792\x0b\x00SERVER_PORT\x02\\ x0080\x0b\x00SERVER_NAME\x10\x00www.mysite.com\t/\\x00HTTP_HOST\x10\x00www.mysite.com\x0f\x00HTTP_CONNECTION')
[26 / May / 2014 06:53:09];
QUERY_STRINGREQUEST_METHODGET
CONTENT_TYPECONTENT_LENGTH
REQUEST_URI
/favicon.ico PATH_INFO
DOCUMENT_ROOT / etc / nginx / htmlSERVER_PROTOCOHTTP / 1.1 /favicon.ico
REMOTE_ADDR
84.94.36.146
REMOTE_PORT51792
SERVER_PORT80
SERVER_NAMEwww.mysite.com HTTP_HOSTwww.mysite.comHTTP_CONNECTION400 -

我读到这个错误可能是由HTTPS请求引起的,但是我似乎没有将HTTP请求重定向到HTTPS,因为我删除了所有这些配置。



任何想法



谢谢

解决方案

>

uwsgi --socket:8001 --wsgi-file test.py



而不是



python manage.py runserser


I have nginx, uwsgi, django stack. There use to be an https serving from the nginx but I'm trying to disable it.

this is my nginx configuration files:

nginx.conf:

events {
worker_connections 768;
# multi_accept on;
}

http {

proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;

##
# 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/*;
}

site-available/mysite.com:

upstream django {
server 127.0.0.1:44000;
}

server {
listen          80 default;
server_name     www.mysite.com mysite.com;


charset         utf-8;
access_log      /var/log/nginx/mysite_access.log;
error_log       /var/log/nginx/mysite_error.log;

location /static/ {
    root   /opt/myapp/myapp/;
    index  index.html index.htm;
}

location / {
  uwsgi_pass  django;
  include     uwsgi_params;
}
}

When I run it with uwsgi i get this error:

django.core.exceptions.SuspiciousOperation: Invalid HTTP_HOST header (you may need to set ALLOWED_HOSTS): www.mysite.com
[pid: 12865|app: 0|req: 1/2] 84.94.36.146 () {36 vars in 571 bytes} [Mon May 26 07:12:55 2014] GET /favicon.ico => generated 0 bytes in 457 msecs (HTTP/1.1 500) 0 headers in 0 bytes (0 switches on core 0)

I put 'www.mysite.com' on my ALLOWED_HOSTS section in settings.py and it didn't help.these are the lines I added in settings.py:

ALLOWED_HOSTS = [
'.mysite.com', # Allow domain and subdomains
'.mysite.com.', # Also allow FQDN and subdomains
]

When I run it with runserver i get this error:

[26/May/2014 06:53:09] code 400, message Bad request syntax ('\x00;\x02\x00\x0c\x00QUERY_STRING\x00\x00\x0e\x00REQUEST_METHOD\x03\x00GET\x0c\x00CONTENT_TYPE\x00\x00\x0e\x00CONTENT_LENGTH\x00\x00\x0b\x00REQUEST_URI\x0c\x00/favicon.ico\t\x00PATH_INFO\x0c\x00/favicon.ico\r\x00DOCUMENT_ROOT\x0f\x00/etc/nginx/html\x0f\x00SERVER_PROTOCOL\x08\x00HTTP/1.1\x0b\x00REMOTE_ADDR\x0c\x0084.94.36.146\x0b\x00REMOTE_PORT\x05\x0051792\x0b\x00SERVER_PORT\x02\x0080\x0b\x00SERVER_NAME\x10\x00www.mysite.com\t\x00HTTP_HOST\x10\x00www.mysite.com\x0f\x00HTTP_CONNECTION')
[26/May/2014 06:53:09] ";
                         QUERY_STRINGREQUEST_METHODGET
                                                      CONTENT_TYPECONTENT_LENGTH
                                                                                REQUEST_URI
                                                                                           /favicon.ico PATH_INFO
DOCUMENT_ROOT/etc/nginx/htmlSERVER_PROTOCOHTTP/1.1                                                               /favicon.ico
                                                  REMOTE_ADDR
                                                             84.94.36.146
                                                                         REMOTE_PORT51792
                                                                                         SERVER_PORT80
                                                                                                      SERVER_NAMEwww.mysite.com HTTP_HOSTwww.mysite.comHTTP_CONNECTION" 400 -

I read that this error may be caused by HTTPS request, but it doesn't seem to me that I redirect HTTP requests to HTTPS anywhere, cause I deleted all those configurations.

any ideas?

Thanks

解决方案

I solved it by using

uwsgi --socket :8001 --wsgi-file test.py

instead of

python manage.py runserser

这篇关于nginx / uwsgi不提供任何请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 19:46