Nginx accumulating writing connections

Viewed 446

I am using Nginx to make WebSocket connections for a Java Spring back-end. However, my Nginx is accumulating connections in the writing state. Everything works normally but with the passing of days, this number increases more and more causing me to need to restart the server.

Already tested several configurations, but the problem still continues... Below I am attaching the Nginx configuration file nginx.conf

user  nginx;
worker_processes  auto;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;

events {
    worker_connections  65535;
    multi_accept       on;
}

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    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;
    reset_timedout_connection on;
    server_tokens        off;

    server_names_hash_bucket_size 64;

    map $http_upgrade $connection_upgrade {
        default upgrade;
        ''      close;
    }

    server {
        listen 80;

        server_name www.mysite.com.br;

        return 301 https://$host$request_uri;
    }

    server {
        listen 443 ssl;
        server_name www.mysite.com.br;
        ssl on;
        ssl_certificate path_to_certificate/fullchain.pem;
        ssl_certificate_key path_to_certificate/privkey.pem;
        ssl_prefer_server_ciphers       on;
        ssl_protocols                   TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers                     ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS;

        location /socket{
            chunked_transfer_encoding off;
            proxy_cache off;

            proxy_http_version 1.1;

            proxy_set_header Connection "Upgrade";
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header X-NginX-Proxy true;
            proxy_request_buffering off;
            proxy_buffering off;

            #proxy_redirect off;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Host $server_name;
            proxy_set_header Host $host;
            proxy_pass http://backend:8080/socket;
        }
    }
}

nginx stub log

Active connections: **1345** 
server accepts handled requests
 10837 10837 11477 
Reading: 0 **Writing: 1342** Waiting: 1 
0 Answers
Related