Python 带有gunicorn和nginx的Django不返回404或500

Python 带有gunicorn和nginx的Django不返回404或500,python,django,nginx,http-status-code-404,gunicorn,Python,Django,Nginx,Http Status Code 404,Gunicorn,如果我使用get\u object\u或\u 404(),Django会显示正确的错误页面,但NGINX仍然返回: HTTP/1.1 200 OK Server: nginx tl;tr 每页返回200或(如果是500)超时。这里怎么了 NGINX配置: location / { proxy_pass http://unix:/opt/repo/page.sock; proxy_set_header X-Forwarded-Host $server_name;

如果我使用
get\u object\u或\u 404()
,Django会显示正确的错误页面,但NGINX仍然返回:

HTTP/1.1 200 OK
Server: nginx
tl;tr

每页返回200或(如果是500)超时。这里怎么了

NGINX配置:

location / {
        proxy_pass http://unix:/opt/repo/page.sock;
        proxy_set_header X-Forwarded-Host $server_name;
        proxy_set_header X-Real-IP $remote_addr;
}
url.py

from django.conf import settings

handler404 = 'my_app.views.page_not_found'

您应该设置处理程序,这可以通过以下方式完成:

from django.utils.functional import curry

handler404 = curry(page_not_found, template_name='404.html')
handler500 = curry(page_not_found, template_name='500.html')
handler403 = curry(page_not_found, template_name='403.html')
我已经在我的url.py中完成了这项工作,但也可以在s中完成