使用uwsgi啓動django代碼,而後打開瀏覽器輸入http://localhost:8000/admin。後臺出現下面錯誤nginx
invalid request block size: 21573 (max 4096)...skip
用nginx來把請求發送給uwsgi。uwsgi被配置成使用socket方式(爲tcp協議)進行通訊。若是打開瀏覽器訪問uwsgi指定的端口,那麼瀏覽器請求uwsgi的方式爲http協議,而不是socket方式。因此就致使uwsgi的log文件中打出上面的錯誤信息。django
解決方法瀏覽器
uwsgi --http :8000 --wsgi-file application.py
uwsgi --ini /patch/to/uwsgi.ini
注意:以上兩種方式啓動不能混用,例如使用uwsgi --http :8000 --ini /path/to/uwsgi.ini會形成端口已經被佔用的錯誤:app
uWSGI http bound on :8000 fd 3 probably another instance of uWSGI is running on the same address (:8000). bind(): Address already in use [core/socket.c line 769]