Django + nginx + gunicorn ошибка при обработке изображений [ upstream преждевременно закрыл соединение при чтении заголовка ответа от upstream ].
Я использую Django, и я полагаю, что это не проблема со стороны Django.
Просто загрузите изображение (~500kb), используя форму модели, и с помощью OpenCV просто преобразуйте его в градации серого (плюс многое другое, если это сработает).
Я настроил с помощью nginx и gunicorn и все функции работают, кроме загрузки и редактирования файлов.
ERROR: upstream prematurely closed connection while reading response header from upstream, client: 174...194, server: .com, запрос: "POST / HTTP/1.1", upstream: "http://unix:/run/gunicorn.sock:/", host: ".com", referrer: "http://****.com/"
Configuration-----------------------
/etc/systemd/system/gunicorn.service
[Unit]
Description=gunicorn daemon
Requires=gunicorn.socket
After=network.target
[Service]
User=shubham
Group=www-data
WorkingDirectory=/home/shubham/editor/src
ExecStart=/home/shubham/editor/venv/bin/gunicorn \
--access-logfile - \
--workers 3 \
--timeout 600 \
--bind unix:/run/gunicorn.sock \
src.wsgi:application
Restart=always
RestartSec=3
[Install]
WantedBy=multi-user.target
/etc/systemd/system/gunicorn.socket
[Unit]
Description=gunicorn socket
[Socket]
ListenStream=/run/gunicorn.sock
[Install]
WantedBy=sockets.target
/etc/nginx/nginx.conf
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
client_max_body_size 10000M;
proxy_connect_timeout 300s;
proxy_read_timeout 300s;
client_body_buffer_size 10000M;
proxy_max_temp_file_size 10000M;
send_timeout 300s;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascr>...
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
#mail {
# # See sample authentication script at:
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen localhost:110;
# protocol pop3;
# proxy on;
# }
#
# server {
# listen localhost:143;
# protocol imap;
# proxy on;
# }
#}
/etc/nginx/sites-available/editor
server {
listen 80;
server_name ****.com;
client_max_body_size 10000M;
proxy_max_temp_file_size 10000M;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /home/shubham/editor/src/static;
}
location /media/ {
root /home/shubham/editor/src/media;
}
location / {
include proxy_params;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_read_timeout 300s;
proxy_connect_timeout 75s;
client_max_body_size 10000M;
client_body_buffer_size 10000M;
proxy_max_temp_file_size 10000M;
send_timeout 300s;
proxy_pass http://unix:/run/gunicorn.sock;
}
}
Журнал ошибок /var/log/nginx/error.log
2023/02/03 06:29:27 [error] 2479#2479: *1 upstream prematurely closed connection while reading response header from upstream, client: 174.***.***.194, server: ****.com, request: "POST / HTTP/1.1", upstream: "http://unix:/run/gunicorn.sock:/", host: "****.com", referrer: "http://****.com/"
Пожалуйста, помогите мне, все файлы конфигурации доступны выше.