I have a fresh installation of an rails app over app Nginx . Everything worked smooth until I decided to put SSL cert from Lets Encrypt . When I try to reach to page I get an 404 Not Found
error .
/error.log
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 {
}
}
}
I've googled it and tried several attempts but nothing changed .
Any help on how should I fix this ?
Best Answer
Your problem is not
worker_connections
. Your problem is that you have specified toproxy_pass
connections back to the very same nginxserver
thus creating an infinite loop. When a connection comes in, nginx immediately reconnects to itself 2048 times, throws that error, and gives up.To solve the problem, you need to
proxy_pass
to the correct web application, wherever it is, or remove it entirely.