Reputation: 2393
As soon as I purchased a domain name and set it up on google domains and then edited my nginx.conf file, I started getting a Bad Request 400 error when I visit my domain. When I visit the IP, everything works fine, no errors. I see NO errors in my log, I configured my log to debug or dev mode (forgot which one) to see more detailed information, and I have pasted the following (digitalocean support isn't sure what the problem is).
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
And Here is my 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
}
If there is nothing wrong here than maybe I made an error on the configuration page for google domains?
Upvotes: 0
Views: 2084
Reputation: 2393
The issue was that I did not configure 'allowed_hosts' in my django settings.py
Upvotes: 1