Request 400 while NGINX Server Block with Django

While I was working on a project requiring multiple website hosted in a same server, I encountered a random issues which happened when request 400 started to pop up in every server blocks I had setup earlier.

After checking all the server blocks incoming request. I discovered that the if I requested domain name started with http://www., the traffic will be routed to one of my server blocks with. Since I only allowed request from the server name to pass through, other domain trying to request the server block will result in a request 400 error.

Screen Shot 2016-09-25 at 12.56.18 PM.pngHence, a good way to counter this issues is to server name with both names( with www. and without www.) . Also remember to set the allowed_host in django settings file to both names .


Although I also found out that setting it to accept all incoming request would yield the same result. Since Nginx will only redirect traffic to their own local server, maybe it will be a better option to simply set it to wild .




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s