gpt4 book ai didi

django - 错误: Invalid HTTP_HOST header: '/webapps/../gunicorn.sock'

转载 作者:行者123 更新时间:2023-12-03 15:20:26 26 4
gpt4 key购买 nike

昨晚部署了Django应用后,我收到了很多奇怪的电子邮件,说:

ERROR: Invalid HTTP_HOST header: '/webapps/example_com/run/gunicorn.sock

我确定这与以下nginx配置有关:
upstream example_app_server {
server unix:/webapps/example_com/run/gunicorn.sock fail_timeout=0;
}

server {

listen 80;
server_name example.com;

client_max_body_size 4G;

access_log /webapps/example_com/logs/nginx-access.log;
error_log /webapps/example_com/logs/nginx-error.log;


location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_set_header Host $http_host;

proxy_redirect off;

if (!-f $request_filename) {
proxy_pass http://example_app_server;
break;
}
}
}

最佳答案

我在django错误报告中找到了我的问题的答案。

    proxy_set_header Host $http_host;

必须替换为:
    proxy_set_header Host $host;

为了使nginx从头传递正确的 header ,而不是在gunicorn套接字上传递请求的页面,因此所请求的页面在django警报中。

关于django - 错误: Invalid HTTP_HOST header: '/webapps/../gunicorn.sock' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21970750/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com