我按照這個教程:http://blog.wercker.com/2013/11/25/django-16-part3.html,我只是想使它現在在本地與流浪漢工作。我不想使用韋克爾。不良要求400:nginx/gunicorn
安裝完成後,我嘗試訪問網站,但每次都收到錯誤的請求(400)錯誤。我不知道這是由於nginx還是gunicorn中的問題。
他們都有一個日誌條目,所以至少我知道請求一直通過gunicorn,並沒有停止在nginx級別。
問題在哪裏? Gunicorn? nginx的?
這裏是gunicorn和nginx的日誌。
我看到favicon缺失,但只是不應該停止顯示頁面正確嗎?
Gunicorn:
>>> cat /var/local/sites/hellocities/run/gunicorn.error.log
10.0.0.1 - - [28/Jan/2014:07:05:16] "GET/HTTP/1.0" 400 - "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.76 Safari/537.36"
10.0.0.1 - - [28/Jan/2014:07:09:43] "GET/HTTP/1.0" 400 - "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.76 Safari/537.36"
Nginx的:
>>> cat /var/log/nginx/hellocities-access.log
10.0.0.1 - - [28/Jan/2014:07:05:16 +0000] "GET/HTTP/1.1" 400 37 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.76 Safari/537.36"
10.0.0.1 - - [28/Jan/2014:07:05:20 +0000] "GET /favicon.ico HTTP/1.1" 404 200 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.76 Safari/537.36"
10.0.0.1 - - [28/Jan/2014:07:09:43 +0000] "GET/HTTP/1.1" 400 37 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.76 Safari/537.36"
10.0.0.1 - - [28/Jan/2014:07:09:44 +0000] "GET /favicon.ico HTTP/1.1" 404 200 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.76 Safari/537.36"
>>> cat /var/log/nginx/hellocities-error.log
2014/01/28 07:05:20 [error] 13886#0: *1 open() "/var/local/sites/hellocities/static/favicon.ico" failed (2: No such file or directory), client: 10.0.0.1, server: _, request: "GET /favicon.ico HTTP/1.1", host: "10.0.0.200"
2014/01/28 07:09:44 [error] 13886#0: *3 open() "/var/local/sites/hellocities/static/favicon.ico" failed (2: No such file or directory), client: 10.0.0.1, server: _, request: "GET /favicon.ico HTTP/1.1", host: "10.0.0.200"
你設置您的settings.py中的ALLOWED_HOSTS? https://docs.djangoproject.com/zh/dev/ref/settings/#allowed-hosts –
嗡嗡聲我想我是的。我用這個命令運行劇本:''ansible-playbook site.yml --extra-vars「source_location = $ REMOTE_SOURCE_DIR hostname = $ HOSTNAME」-u root''其中''HOSTNAME''爲''127.0.0.1' '。然後在tuto的腳本中,通過'export DJANGO_ALLOWED_HOST = {{hostname}}''和''ALLOWED_HOSTS = [os.environ.get('DJANGO_ALLOWED_HOST','127.0.0.1')]設置變量。 '' – Michael
好吧,你是對的,它是''DJANGO_ALLOWED_HOST''變量。 我在設置文件中設置了''ALLOWED_HOSTS = ['*']'',它工作正常。 但是我不明白在使用當地流浪漢的時候應該放置什麼樣的價值......? ''127.0.0.1''不起作用... 非常感謝。 – Michael