2

I'm running my Django app in a Docker container with nginx as the webserver, and uWSGI as the app server. Everything is deployed on AWS Elastic Beanstalk. When I set DEBUG=False, all the requests result in Bad Request (400). I have tried both ALLOWED_HOSTS='*' and ALLOWED_HOSTS=['*'], and I still get the same error. I verified the request is coming to uWSGI by checking the logs. The uWSGI logs have this:

[pid: 33|app: 0|req: 4/4] 172.17.0.1 () {46 vars in 855 bytes} [Tue Aug  1 02:54:17 2017] GET / => generated 26 bytes in 26 msecs (HTTP/1.1 400) 1 headers in 53 bytes (1 switches on core 0)

I've tried a bunch of answers, but no luck. I've tried this answer, but I still get the same error. Is there anything else that could cause this?

This question is different from this question, because, as I mentioned, setting ALLOWED_HOSTS to wildcard did not work for me. From the same question, I also tried this answer, and I still get the same error.

user2233706
  • 6,148
  • 5
  • 44
  • 86
  • Can the admins/someone please remove the tag that this is a duplicate? I noted that I had tried out the solution specified in the supposed duplicate question when I created the question and only clarified it when prompted. – user2233706 Aug 02 '17 at 00:43

1 Answers1

1

The problem is that my URL has an underscore, and Django does not allow underscores anywhere in the URL. I had www._test_.example.com. www._test.example.com and www.a_test.example.com don't work either. Underscores should be valid characters in URLs.

user2233706
  • 6,148
  • 5
  • 44
  • 86