即使将数量增加一倍,仍然“worker_connections 不足”

即使将数量增加一倍,仍然“worker_connections 不足”

我在 Nginx 上全新安装了 rails 应用。一切运行顺利,直到我决定从 Lets Encrypt 导入 SSL 证书。当我尝试访问页面时出现错误404 Not Found

/错误日志

2017/02/07 02:10:46 [alert] 4779#0: *35005 2048 worker_connections are not enough while connecting to upstream

/etc/nginx/nginx.conf

    user  nginx;
worker_processes  2;
worker_rlimit_nofile 30000;

error_log  /var/log/nginx/error.log;
#error_log  /var/log/nginx/error.log  notice;
#error_log  /var/log/nginx/error.log  info;

pid        /run/nginx.pid;


events {
    worker_connections  2048;
}

 server{
        listen  80;
        server_name  example.com www.example.com;
        return 301 https://$host$request_uri;
}

        server{

        listen  443 ssl;
        server_name  example.com www.example.com;
        root         /var/www/myapp/public;

        #SSL Configuration

        ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_prefer_server_ciphers on;
        ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';

        #charset koi8-r;

        #access_log  /var/log/nginx/host.access.log  main;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        location / {
                proxy_pass https://example.com;
        }

        # redirect server error pages to the static page /40x.html
        #
        error_page  404              /404.html;
        location = /40x.html {
        }

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
        }
 }
}

我已经在 Google 上搜索过并尝试了几次,但没有任何变化。有人能帮我解决这个问题吗?

答案1

你的问题不是worker_connections。你的问题是你指定了到proxy_pass同一个 nginx 的连接,server从而造成了无限循环。当一个连接进来时,nginx 立即重新连接到自身 2048 次,抛出该错误,然后放弃。

要解决这个问题,您需要proxy_pass转到正确的 Web 应用程序(无论它在哪里),或者将其完全删除。

相关内容