访问域名时出现错误请求400错误,但IP加载网站正常

时间:2015-06-29 20:53:30

标签: nginx dns

一旦我购买了域名并在google域上进行了设置,然后编辑了我的nginx.conf文件,当我访问我的域时,我就开始收到错误请求400错误。当我访问IP时,一切正常,没有错误。我在日志中看到没有错误,我将我的日志配置为调试或开发模式(忘了哪一个)以查看更多详细信息,我已粘贴以下内容(digitalocean支持不确定问题是什么)。

2015/06/21 23:38:41 [debug] 32730#0: epoll add event: fd:6 op:1 ev:00000001 
2015/06/21 23:38:41 [debug] 32730#0: epoll add event: fd:7 op:1 ev:00000001 
2015/06/21 23:38:47 [debug] 32730#0: post event 0000000000E0F930 
2015/06/21 23:38:47 [debug] 32730#0: delete posted event 0000000000E0F930 
2015/06/21 23:38:47 [debug] 32730#0: accept on 0.0.0.0:80, ready: 0 
2015/06/21 23:38:47 [debug] 32730#0: posix_memalign: 0000000000DE1060:256 @16 
2015/06/21 23:38:47 [debug] 32730#0: *1 accept: 71.20.1.73 fd:10 
2015/06/21 23:38:47 [debug] 32730#0: *1 event timer add: 10: 60000:1434944387419 
2015/06/21 23:38:47 [debug] 32730#0: *1 reusable connection: 1 
2015/06/21 23:38:47 [debug] 32730#0: *1 epoll add event: fd:10 op:1 ev:80000001 
2015/06/21 23:38:47 [debug] 32730#0: *1 post event 0000000000E0FA68 
2015/06/21 23:38:47 [debug] 32730#0: *1 delete posted event 0000000000E0FA68 
2015/06/21 23:38:47 [debug] 32730#0: *1 http wait request handler 
2015/06/21 23:38:47 [debug] 32730#0: *1 posix_memalign: 0000000000E0DC90:256 @16 
2015/06/21 23:38:47 [debug] 32730#0: *1 malloc: 0000000000DEEA80:1024 
2015/06/21 23:38:47 [debug] 32730#0: *1 recv: fd:10 378 of 1024 
2015/06/21 23:38:47 [debug] 32730#0: *1 reusable connection: 0 
2015/06/21 23:38:47 [debug] 32730#0: *1 posix_memalign: 0000000000DEEE90:4096 @16 
2015/06/21 23:38:47 [debug] 32730#0: *1 http process request line 
2015/06/21 23:38:47 [debug] 32730#0: *1 http request line: "GET / HTTP/1.1" 
2015/06/21 23:38:47 [debug] 32730#0: *1 http uri: "/" 
2015/06/21 23:38:47 [debug] 32730#0: *1 http args: "" 
2015/06/21 23:38:47 [debug] 32730#0: *1 http exten: "" 
2015/06/21 23:38:47 [debug] 32730#0: *1 http process request header line 
2015/06/21 23:38:47 [debug] 32730#0: *1 http header: "Host: cannablr.com" 
2015/06/21 23:38:47 [debug] 32730#0: *1 http header: "Connection: keep-alive" 
2015/06/21 23:38:47 [debug] 32730#0: *1 http header: "Cache-Control: max-age=0" 
2015/06/21 23:38:47 [debug] 32730#0: *1 http header: "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8" 
2015/06/21 23:38:47 [debug] 32730#0: *1 http header: "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36" 
2015/06/21 23:38:47 [debug] 32730#0: *1 http header: "Accept-Encoding: gzip, deflate, sdch" 
2015/06/21 23:38:47 [debug] 32730#0: *1 http header: "Accept-Language: en-US,en;q=0.8" 
2015/06/21 23:38:47 [debug] 32730#0: *1 http header done 
2015/06/21 23:38:47 [debug] 32730#0: *1 event timer del: 10: 1434944387419 
2015/06/21 23:38:47 [debug] 32730#0: *1 generic phase: 0 
2015/06/21 23:38:47 [debug] 32730#0: *1 rewrite phase: 1 
2015/06/21 23:38:47 [debug] 32730#0: *1 test location: "/" 
2015/06/21 23:38:47 [debug] 32730#0: *1 using configuration "/" 
2015/06/21 23:38:47 [debug] 32730#0: *1 http cl:-1 max:4294967296 
2015/06/21 23:38:47 [debug] 32730#0: *1 rewrite phase: 3 
2015/06/21 23:38:47 [debug] 32730#0: *1 post rewrite phase: 4 
2015/06/21 23:38:47 [debug] 32730#0: *1 generic phase: 5 
2015/06/21 23:38:47 [debug] 32730#0: *1 generic phase: 6 
2015/06/21 23:38:47 [debug] 32730#0: *1 generic phase: 7 
2015/06/21 23:38:47 [debug] 32730#0: *1 access phase: 8 
2015/06/21 23:38:47 [debug] 32730#0: *1 access phase: 9 
2015/06/21 23:38:47 [debug] 32730#0: *1 post access phase: 10 
2015/06/21 23:38:47 [debug] 32730#0: *1 posix_memalign: 0000000000DE55A0:4096 @16 
2015/06/21 23:38:47 [debug] 32730#0: *1 http init upstream, client timer: 0 
2015/06/21 23:38:47 [debug] 32730#0: *1 epoll add event: fd:10 op:3 ev:80000005 
2015/06/21 23:38:47 [debug] 32730#0: *1 http script copy: "X-Forwarded-For: " 
2015/06/21 23:38:47 [debug] 32730#0: *1 http script var: "71.20.1.73" 
2015/06/21 23:38:47 [debug] 32730#0: *1 http script copy: " 
" 
2015/06/21 23:38:47 [debug] 32730#0: *1 http script copy: "Host: " 
2015/06/21 23:38:47 [debug] 32730#0: *1 http script var: "cannablr.com" 
2015/06/21 23:38:47 [debug] 32730#0: *1 http script copy: " 
" 
2015/06/21 23:38:47 [debug] 32730#0: *1 http script copy: "Connection: close 
" 
2015/06/21 23:38:47 [debug] 32730#0: *1 http script copy: "" 
2015/06/21 23:38:47 [debug] 32730#0: *1 http script copy: "" 
2015/06/21 23:38:47 [debug] 32730#0: *1 http proxy header: "Cache-Control: max-age=0" 
2015/06/21 23:38:47 [debug] 32730#0: *1 http proxy header: "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8" 
2015/06/21 23:38:47 [debug] 32730#0: *1 http proxy header: "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36" 
2015/06/21 23:38:47 [debug] 32730#0: *1 http proxy header: "Accept-Encoding: gzip, deflate, sdch" 
2015/06/21 23:38:47 [debug] 32730#0: *1 http proxy header: "Accept-Language: en-US,en;q=0.8" 
2015/06/21 23:38:47 [debug] 32730#0: *1 http proxy header: 
"GET / HTTP/1.0 
X-Forwarded-For: 71.20.1.73 

这是我的nginx.conf

upstream app_server { 
server 127.0.0.1:9000 fail_timeout=0; 
}

server { 
listen 80 default_server; 
listen [::]:80 default_server ipv6only=on;

root /usr/share/nginx/html; 
index index.html index.htm;

client_max_body_size 4G; 
server_name cannablr.com www.cannablr.com;

keepalive_timeout 5;

# Your Django project's media files - amend as required 
location /media { 
alias /home/django/django/dealr/dealr/media; 
}

# your Django project's static files - amend as required 
location /static { 
alias /home/django/django/dealr/dealr/static; 
} 

location /favicon.ico { 
alias /home/django/django/dealr/favicon.ico; 
}

location / { 
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
proxy_set_header Host $http_host; 
proxy_redirect off; 
proxy_pass http://app_server; 
} 
}

I also have a file called default:

server {

listen 80 default_server; 
listen [::]:80 default_server ipv6only=on;

root /usr/share/nginx/html; 
index index.html index.htm;

# Make site accessible from http://localhost/ 
server_name localhost;

location / { 
# First attempt to serve request as file, then 
# as directory, then fall back to displaying a 404. 
try_files $uri $uri/ =404; 
# Uncomment to enable naxsi on this location 
# include /etc/nginx/naxsi.rules 
}

如果这里没有任何错误,可能是我在谷歌域名的配置页面上出错了?

1 个答案:

答案 0 :(得分:0)

问题是我没有配置' allowed_hosts'在我的django settings.py