我正在尝试使用docker运行django应用程序,我正在使用存在的cookiecutter-django template。但是,在尝试运行应用程序时,我收到以下错误:
错误请求(400)
从终端查看日志时,我看到以下内容:
django_1 | [2015-12-18 17:08:04 +0000] [15] [INFO] Booting worker with pid: 15
django_1 | [2015-12-18 17:08:04 +0000] [16] [INFO] Booting worker with pid: 16
django_1 | [2015-12-18 17:08:04 +0000] [18] [INFO] Booting worker with pid: 18
django_1 | [2015-12-18 17:08:04 +0000] [20] [INFO] Booting worker with pid: 20
django_1 | ERROR 2015-12-18 18:08:07,072 base 18 140496642320128 Invalid HTTP_HOST header: '192.168.99.100'. You may need to add '192.168.99.100' to ALLOWED_HOSTS.
nginx_1 | 192.168.99.1 - - [18/Dec/2015:17:08:08 +0000] "GET /admin HTTP/1.1" 400 37 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36" "-"
django_1 | ERROR 2015-12-18 18:08:08,570 base 20 140496642320128 Invalid HTTP_HOST header: '192.168.99.100'. You may need to add '192.168.99.100' to ALLOWED_HOSTS.
nginx_1 | 192.168.99.1 - - [18/Dec/2015:17:08:09 +0000] "GET /favicon.ico HTTP/1.1" 400 37 "http://192.168.99.100/admin" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36" "-"
django_1 | ERROR 2015-12-18 18:08:09,842 base 18 140496642320128 Invalid HTTP_HOST header: '192.168.99.100'. You may need to add '192.168.99.100' to ALLOWED_HOSTS.
nginx_1 | 192.168.99.1 - - [18/Dec/2015:17:08:11 +0000] "GET /favicon.ico HTTP/1.1" 400 37 "http://192.168.99.100/admin" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36" "-"
这很奇怪,因为我已经将192.168.99.100添加到了ALLOWED_HOSTS(也试过[“*”]),所以我真的不明白这个错误的来源。
答案 0 :(得分:0)
所以最后括号产生了错误,因为主机是在我的环境变量中设置的。在没有括号的情况下添加*
(或实际主机)。