Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Django 在/etc/nginx/conf.d/default.conf:1中不允许使用“http”指令_Django_Nginx - Fatal编程技术网

Django 在/etc/nginx/conf.d/default.conf:1中不允许使用“http”指令

Django 在/etc/nginx/conf.d/default.conf:1中不允许使用“http”指令,django,nginx,Django,Nginx,我不能在nginx配置文件上放置http块/指令,我试图通过curl增加文件上传的超时时间,它说/etc/nginx/conf.d/default.conf:1中不允许使用http指令 我正在使用django,但我似乎无法解决它 http { fastcgi_read_timeout 300; proxy_read_timeout 300; server { listen 80; server_name localhost;

我不能在nginx配置文件上放置http块/指令,我试图通过curl增加文件上传的超时时间,它说/etc/nginx/conf.d/default.conf:1中不允许使用http指令

我正在使用django,但我似乎无法解决它

http {
    fastcgi_read_timeout 300;
    proxy_read_timeout 300;

    server {
        listen       80;
        server_name  localhost;

        location /media/ {
            try_files $uri /dev/null =404;
        }

        location / {
            proxy_redirect     off;
            proxy_set_header   Host $host;
            proxy_set_header   X-Real-IP $remote_addr;
            proxy_set_header   X-Forwarded-For 
            $proxy_add_x_forwarded_for;
            proxy_set_header   X-Forwarded-Proto $scheme;
            proxy_set_header   X-Forwarded-Host $server_name;
            proxy_pass         http://app:8000;
            client_max_body_size 100M;
            proxy_temp_file_write_size 64k;
            proxy_connect_timeout 10080s;
            proxy_send_timeout 10080;
            proxy_read_timeout 10080;
            proxy_buffer_size 64k;
            proxy_buffers 16 32k;
            proxy_busy_buffers_size 64k;
            proxy_redirect off;
            proxy_request_buffering off;
            proxy_buffering off;
        }
    }
}
http指令已在/etc/nginx/nginx.conf中使用。打开它,您会发现include/etc/nginx/conf.d/*.conf;在文件的末尾


解决方案:从/etc/nginx/conf.d/default.conf中删除http指令。您可以更改*\u read\u timeout参数,无论是在server指令内部还是外部

我在目录/etc/nginx/nginx.conf中找不到这个文件,而且我使用的是docker,所以所有依赖项都在我当前的项目文件夹下,没有其他内容。我也尝试过更改服务器块上的读取超时,但没有发生任何事情,这就是为什么我添加了协议级超时,但无法正常工作。@bonvivantsentoy在位置/{}下还有代理读取超时。您的意思是将其更改为300s吗?我找不到文件nginx.conf,但是删除http块,然后将代理超时置于服务器块之上解决了问题,似乎有一个默认的nginx conf我找不到。@bonvivantsentoy因为您使用的是Docker,您只能在Docker容器中找到文件,但不能在主机系统中找到文件。按照以下答案访问容器: