Puma stuck, can not connect from nginx - ruby-on-rails

I'm working with nginx and single puma, It working normally but suddenly nginx can not connect to puma and I got some error from nginx like
*11193882 epoll_wait() reported that client prematurely closed connection, so upstream connection is closed too while sending request to upstream, client: xxx.xx.xx.xx, server: _, request: "GET /ping HTTP/1.1", upstream: "http://unix:////tmp/sockets/puma.sock:/ping", host: "host_name"
I don't know why puma stuck and can not connect from nginx with no error from puma_error.log
Check CPU no problem
Check memory no problem
No error on puma_error.log
Does anyone has ideal for this problem? How do I know where the problem is coming from?

Related

How to config nginx so that it listens to one port and proxies requests to other port?

I have two docker containers which are running on local Ubuntu machine.
The first one is nodejs service that listen to port 3010, the second one is nginx server on port 2010.
I need to handle all the requests come to port 2010 (matched '/login') and pass them to the first container.
I have nginx.conf as below:
server {
listen 2010;
server_name 127.0.0.1;
root /usr/share/nginx/html;
location ^~ /login {
proxy_pass http://127.0.0.1:3010$request_uri;
}
}
I try to do request from Postman, and get an error:
[error] 29#29: *1 connect() failed (111: Connection refused) while connecting to
upstream, client: 172.17.0.1, server: 127.0.0.1, request: "GET /login HTTP/1.1",
upstream: "http://127.0.0.1:3010/login", host: "127.0.0.1:2010"
Where am I wrong and what am I doing not properly?
127.0.0.1 refers to the nginx server/container itself, not any external services/containers.
Doubtful you're running Nodejs processes within the nginx container, so you need to refer to the other container with service names - https://docs.docker.com/network/bridge/

Deploy Java jar on App Engine Flexible is failing because of health checks

During the deployment GAE health checks are failing because of connection refused error. Container is exposing same port as GAE expects - 8080. After connecting with SSH to the container and doing curl 127.0.0.1/liveness_check, it works, however trying to manually query from gae instance itself is resulting with connection refused error.
Disabling health checks allows the deployment to finish but when accessing the service URL we receive nginx 502 bad gateway error.
Looks like nginx cannot access container port, or something else, I did try to deploy the image on GCE and it works.
app.yaml is pretty standard, it's using a custom VPC.
From GAE service logs:
[error] 33#33: *407 connect() failed (111: Connection refused) while connecting to upstream, client: 172.217.20.180, server: , request: "GET / HTTP/1.1", upstream: "http://172.17.0.1:8080/", host: "XXXXXXXXX"

NGINX and SPRINGBOOT in DOCKER container GOT 502 Bad Gateway

I deployed my springboot project in docker container opening port 8080 as well as an nginx server opening port 80
enter image description here
When I use
curl http://localhost:8080/heya/index
it returns normally
But when I use
curl http://localhost/heya/index
hoping I can reach from nginx proxy,it failed. And I checked the log, it says
*24#24: 11 connect() failed (111: Connection refused) while connecting to upstream, client: 172.17.0.1, server: , request: "GET /heya/index HTTP/1.1", upstream: "http://127.0.0.1:8080/heya/index", host: "localhost"
Here is my nginx.conf
enter image description here
I cannot figure it out and need help.
I finally got the answer!!
I ran nginx container and webapp container using host network mode, and it worked.
111: Connection refused) while connecting to upstream
is saying Nginx can't connect to the upstream server.
Your
proxy_pass http://heya;
is telling Nginx that the upstream is talking the HTTP protocol [on the default port 80] on the hostname heya. Unless you're running multiple containers in the same Compose network, it's unlikely that the hostname would be heya.
If the Java application is running on port 8080 inside the same container, talking the HTTP protocol, the correct proxy_pass would be
proxy_pass http://localhost:8080;
(since localhost in the container's view is the container itself).

Rasa X deployment on shared server

I m trying to deploy rasa on my shared server. I have follow the Docker Compose Installation documentation to deploy rasa. And tried both with script and manual deployment. But it's not working.
As it shared server my 80 and 443 ports are used, therefore i change rasa/nginx container ports to 8080 and 8443, in docker-compose.yml file
When I hit to http://<server_ip>:8080 its get redirected to http://<server_ip>/api/health and finally shows unable to connect.
And when I hit url http://<server_ip>:8080/conversations then it shows blank page with title "Rasa X".
Edit:
Still not able to figure out what was the issue. But now url http://<server_ip>:8080/ returning 502 Bad Gateway
From log docker-compose logs:
[error] 17#17: *40 connect() failed (111: Connection refused) while connecting to upstream, client: 43.239.112.255, server: , request: "GET / HTTP/1.1", upstream: "http://192.168.64.6:5002/", host: "http://<server_ip>:8080"
Any idea what causing it?
It seem that RASA X 0.35.0 is not compatible with RASA OPEN SOURCE 2.2.4 on server.
When I changed versions, from
RASA_X_VERSION=0.35.0
RASA_VERSION=2.2.4
RASA_X_DEMO_VERSION=0.35.0
to
RASA_X_VERSION=0.34.0
RASA_VERSION=2.1.2
RASA_X_DEMO_VERSION=0.34.0
Then it's works.
Can you also define the ports in config.yml file as shown below for duckling server

502 Bad Gateway Error for Nginx & Passenger in Rails 3.1

Hi my server suddenly failed. I tried to restart nginx using sudo service nginx restart but it failed.
Then looking to error.log
2014/01/03 10:11:44 [crit] 31821#0: *699 connect() to /tmp/passenger.1.0.18076/generation-1/request failed (2: No such file or directory) while connecting to upstream, client: 00.00.00.00, server: staging.com, request: "GET / HTTP/1.1", upstream: "passenger:/tmp/passenger.1.0.18076/generation-1/request:", host: "test.co"
Any workarounds will be appreciated.
There is probably a /tmp cleaner daemon on your system that deletes essential Passenger socket files, resulting in the failure you see. Try setting passenger_temp_dir to some directory that is not /tmp: http://www.modrails.com/documentation/Users%20guide%20Nginx.html#PassengerTempDir

Resources