در نرم افزاری طول URL از حدی که بیشتر میشد سرور ارور بر میگردوند. با بررسی لاگ Nginx و uWSIG متوجه شدم که سایز هدری که مرورگر میفرسته از حدی بیشتره و سرور قبول نمیکنه. از طرفی اون عملیات زمان بر هم بود و وقتی که سایز هدر را هم بیشتر کردم باز هم چون طول میکشید سرور کانکشن رو میبست. با تنظیمات Nginx زیر تونستم هم طول هدر رو بیشتر کنم هم مدت زمان کانکشن ها:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; client_header_timeout 600s; client_body_timeout 600s; send_timeout 600s; # limits the size of the client request body client_max_body_size 50M; # These parameters control the buffer sizes used by NGINX when proxying responses from the upstream (uWSGI). Increasing buffer sizes allows NGINX to handle larger responses without having to offload data to disk proxy_buffers 4 256k; proxy_buffer_size 256k; proxy_busy_buffers_size 256k; # Increase buffer sizes to handle long URLs client_header_buffer_size 512k; large_client_header_buffers 4 256k; # This is the time NGINX waits for uWSGI proxy_connect_timeout 600s; proxy_read_timeout 600s; proxy_send_timeout 600s; # upstream myuwsgi { # server myuwsgi:8000; # } server { listen 80; location / { proxy_pass http://myuwsgi:8000; 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; } location /ws/ { proxy_pass http://daphne:8001; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; 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; } location /static/ { alias /static/; } } } |
فایل compose کل سرویس ها هم مثل زیره:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
version: '3.8' services: nasim: image: myuwsgiproject:latest #build: # context: . # dockerfile: Dockerfile hostname: uwsgiproject container_name: uwsgiproject volumes: - ./app:/opt/app - ./data:/opt/data expose: - "8000" environment: - DJANGO_SETTINGS_MODULE=core.settings command: > uwsgi --http 0.0.0.0:8000 --module core.wsgi:application --master --processes 4 --threads 4 --buffer-size 163840 --http-timeout 300 --harakiri 300 daphne: #image: nasimproject-daphne:latest build: context: . dockerfile: DockerfileDaphne hostname: daphne container_name: daphne volumes: - ./app:/opt/app - ./data:/opt/data expose: - "8001" environment: - DJANGO_SETTINGS_MODULE=core.settings nginx: image: uwsgiproject-nginx:latest #build: # context: . # dockerfile: DockerfileNginx hostname: nginx container_name: nginx ports: - "80:80" depends_on: - nasim - daphne volumes: - ./app/static:/static - ./nginx/nginx.conf:/etc/nginx/nginx.conf rabbit: hostname: rabbit container_name: rabbit image: rabbitmq:3-management environment: - RABBITMQ_DEFAULT_USER= - RABBITMQ_DEFAULT_PASS= ports: - "5672:5672" - "15672:15672" celery: build: context: . dockerfile: DockerfileCelery hostname: celery container_name: celery volumes: - ./app:/opt/app beat: build: context: . dockerfile: DockerfileBeat hostname: beat container_name: beat volumes: - ./app:/opt/app |