前回の質問
https://teratail.com/questions/304864
で40MバイトのCSVファイルをインポートしようとしたところエラーになり、質問時点ではnginx.confの設定を行っていましたが、質問後gunicornの設定を追加で行うことで50MバイトのCSVファイルをインポートすることに成功したため自己解決としたところ、100MバイトのCSVファイルインポート時にエラーになってしまいました。表題の通り1Gバイトのファイルをインポートしたいため設定内容を見直しておりますが、よくわかりません。ブラウザに表示されるものに関しては「Server Error (500)」や「nginx error!」です。
以下に設定ファイルと100Mバイトのファイルのインポート時のログ情報を記述します。
nginx.con(client_max_body_sizeとして1Gを設定しました)
user nginx; worker_processes auto; error_log /var/log/nginx/error.log; pid /run/nginx.pid; # Load dynamic modules. See /usr/share/doc/nginx/README.dynamic. include /usr/share/nginx/modules/*.conf; events { worker_connections 1024; } http { log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; # keepalive_timeout 65; keepalive_timeout 9999; types_hash_max_size 4096; include /etc/nginx/mime.types; default_type application/octet-stream; # Load modular configuration files from the /etc/nginx/conf.d directory. # See http://nginx.org/en/docs/ngx_core_module.html#include proxy_connect_timeout 9999; proxy_send_timeout 9999; proxy_read_timeout 9999; send_timeout 9999; client_body_timeout 9999; client_header_timeout 9999; server { # 80番ポート(HTTP)でリクエストを待機する設定 listen 80; listen [::]:80; # ElasticIPアドレスを指定 server_name xxx.xxx.xxx.xxx; # 公開するディレクトリの設定 root /usr/share/nginx/html; client_max_body_size 1G; # 下記は必要な場合とない場合があるが記述しておく # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; # 静的ファイル配置ディレクトリとURLの対応付け location /static { alias /usr/share/nginx/html/static; } location / { # Host:ホスト名を転送 proxy_set_header Host $http_host; # X-Forwarded-For:送信元アドレスを転送 proxy_set_header X-Fowarded-For $proxy_add_x_forwarded_for; # X-Forwarded-Proto:URLスキーム(httpなど)を転送 proxy_set_header X-Fowrded-Proto $scheme; #client_max_body_size 1000M; client_max_body_size 1G; # URLが「/static」に該当しない場合(リバースプロキシ) proxy_pass http://127.0.0.1:8000; } error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } } }
/var/log/nginx/error.log
(venv_xxx_project) [app_admin@ip-172-31-36-217 ~]$ sudo tail -f /var/log/nginx/error.log 2020/11/18 14:02:48 [error] 12701#0: *1 client intended to send too large body: 102416786 bytes, client: yyy.yyy.yyy.yyy, server: xxx.xxx.xxx.xxx, request: "POST /working_listworkinglistimport/ HTTP/1.1", upstream: "http://127.0.0.1:8000/working_listworkinglistimport/", host: "xxx.xxx.xxx.xxx", referrer: "http://xxx.xxx.xxx.xxx/working_listworkinglistimport/" 2020/11/18 14:04:56 [emerg] 12773#0: "client_body_buffer_size" directive invalid value in /etc/nginx/nginx.conf:61 2020/11/18 14:05:46 [emerg] 12787#0: "client_body_buffer_size" directive invalid value in /etc/nginx/nginx.conf:61 2020/11/18 14:05:52 [emerg] 12801#0: "client_body_buffer_size" directive invalid value in /etc/nginx/nginx.conf:61 2020/11/18 14:08:35 [error] 12827#0: *2 upstream prematurely closed connection while reading response header from upstream, client: yyy.yyy.yyy.yyy, server: xxx.xxx.xxx.xxx, request: "POST /working_listworkinglistimport/ HTTP/1.1", upstream: "http://127.0.0.1:8000/working_listworkinglistimport/", host: "xxx.xxx.xxx.xxx", referrer: "http://xxx.xxx.xxx.xxx/working_listworkinglistimport/" 2020/11/18 14:27:08 [emerg] 13007#0: *1 malloc(1024164151) failed (12: Cannot allocate memory), client: yyy.yyy.yyy.yyy, server: xxx.xxx.xxx.xxx, request: "POST /working_listworkinglistimport/ HTTP/1.1", host: "xxx.xxx.xxx.xxx", referrer: "http://xxx.xxx.xxx.xxx/working_listworkinglistimport/" 2020/11/18 14:27:38 [emerg] 13007#0: *3 malloc(1024164151) failed (12: Cannot allocate memory), client: yyy.yyy.yyy.yyy, server: xxx.xxx.xxx.xxx, request: "POST /working_listworkinglistimport/ HTTP/1.1", host: "xxx.xxx.xxx.xxx", referrer: "http://xxx.xxx.xxx.xxx/working_listworkinglistimport/" 2020/11/18 14:28:08 [emerg] 13007#0: *4 malloc(1024164151) failed (12: Cannot allocate memory), client: yyy.yyy.yyy.yyy, server: xxx.xxx.xxx.xxx, request: "POST /working_listworkinglistimport/ HTTP/1.1", host: "xxx.xxx.xxx.xxx", referrer: "http://xxx.xxx.xxx.xxx/working_listworkinglistimport/" 2020/11/18 14:32:53 [error] 13049#0: *1 sendfile() failed (104: Connection reset by peer) while sending request to upstream, client: yyy.yyy.yyy.yyy, server: xxx.xxx.xxx.xxx, request: "POST /working_listworkinglistimport/ HTTP/1.1", upstream: "http://127.0.0.1:8000/working_listworkinglistimport/", host: "xxx.xxx.xxx.xxx", referrer: "http://xxx.xxx.xxx.xxx/working_listworkinglistimport/" 2020/11/18 14:49:35 [error] 13406#0: *1 upstream prematurely closed connection while reading response header from upstream, client: yyy.yyy.yyy.yyy, server: xxx.xxx.xxx.xxx, request: "POST /working_listworkinglistimport/ HTTP/1.1", upstream: "http://127.0.0.1:8000/working_listworkinglistimport/", host: "xxx.xxx.xxx.xxx", referrer: "http://xxx.xxx.xxx.xxx/working_listworkinglistimport/" 2020/11/18 15:13:46 [error] 13553#0: *5 upstream prematurely closed connection while reading response header from upstream, client: yyy.yyy.yyy.yyy, server: xxx.xxx.xxx.xxx, request: "POST /working_listworkinglistimport/ HTTP/1.1", upstream: "http://127.0.0.1:8000/working_listworkinglistimport/", host: "xxx.xxx.xxx.xxx", referrer: "http://xxx.xxx.xxx.xxx/working_listworkinglistimport/"
django.log
(venv_xxx_project) [app_admin@ip-172-31-36-217 xxx_project]$ tail -f logs/django.log self.full_clean() File "/home/app_admin/venv_xxx_project/lib64/python3.7/site-packages/django/forms/forms.py", line 376, in full_clean self._clean_fields() File "/home/app_admin/venv_xxx_project/lib64/python3.7/site-packages/django/forms/forms.py", line 397, in _clean_fields value = getattr(self, 'clean_%s' % name)() File "/home/app_admin/venv_xxx_project/xxx_nippo_20201102/venv_xxx_project/xxx_project/working_list/forms.py", line 26, in clean_file for row in reader: MemoryError 2020-11-18 15:08:01,058 [WARNING] /home/app_admin/venv_xxx_project/lib64/python3.7/site-packages/django/utils/log.py(Line:228) Not Found: /.env 2020-11-18 15:08:03,157 [WARNING] /home/app_admin/venv_xxx_project/lib64/python3.7/site-packages/django/utils/log.py(Line:228) Not Found: / 2020-11-18 15:13:46,996 [WARNING] /home/app_admin/venv_xxx_project/lib64/python3.7/site-packages/django/utils/log.py(Line:228) Not Found: /nginx-logo.png 2020-11-18 15:13:46,998 [WARNING] /home/app_admin/venv_xxx_project/lib64/python3.7/site-packages/django/utils/log.py(Line:228) Not Found: /poweredby.png
環境
インスタンスタイプ:t2.micro
ap:django
web:nginx(gunicorn)
db:PostgreSQL
急ぎ対応に当たっており、尚早に自己解決としてしまったため2度手間になってしまいましたが、どんなことでも構いません、何か見落としている点があれば教えて下さい。よろしくお願いいたします。*文字数の関係で下記にgunicornのログを追記します。
回答2件
あなたの回答
tips
プレビュー