502 Bad Gateway nginx/1.10.3 (Ubuntu)?

Trying to deploy a Rails project using pumu.
I get a 502 error in the browser when trying to access the page via ip address and server name, the page did not find.
In the logs gives this error:

2017/12/17 20:46:08 [error] 12589#12589: *4 connect() failed (113: No route to host) while connecting to upstream, client: 10.50.60.2, server: 10.12.4.245, request: "GET /favicon.ico HTTP/1.1", upstream: "http://10.12.4.245:80/favicon.ico", host: "10.12.4.242", referrer: "http://10.12.4.242/"


Puma and nginx running too if that.
June 10th 19 at 14:25
1 answer
June 10th 19 at 14:27
ip address of the server to which nginx is trying to connect the client belongs to another subnet than the ip address of the server with nginx, and route to that subnet on the server that nginx is missing. either need to fix the subnet mask on one or both servers, or the ip address on one or both servers, or to deal with the routing between these two subnets.
can help please, I just don't quite understand

upstream puma {
 server unix:///var/www/phonebook-api/tmp/sockets/puma.sock;
}
server {
listen 80 default;
listen [::]:80 default ipv6only=on;

server_name 10.12.4.245;
charset utf-8;
root /var/www/phonebook-api;

 access_log /var/log/nginx/access.log;
 error_log /var/log/nginx/error.log;

location / {
root phonebook-app/dist;
index index.html index.htm;
try_files $uri @app;
 gzip_static on;
 expires max;
 proxy_read_timeout 150;
 add_header Cache-Control public;
}
 try_files $uri/index.html $uri @puma;
 location @puma {
 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 proxy_set_header Host $http_host;
 "proxy_redirect" off;
 proxy_pass <a href="http://puma;">http://puma;</a>
}
 location @app {
 proxy_pass <a href="http://10.12.4.245;">http://10.12.4.245;</a>
 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 http;
 proxy_set_header Host $http_host ;
 "proxy_redirect" off;
 "proxy_next_upstream" error timeout invalid_header are http_502;
}

 client_max_body_size 50M;
 keepalive_timeout 10;
}
- nikita.Stracke commented on June 10th 19 at 14:30
the project on rails and nginx on the same machine or on different? what is the car with the address 10.50.60.2? what is the car with the address 10.12.4.245? what is the subnet mask of the interface address 10.50.60.2? what is the subnet mask of the interface address 10.12.4.245? - shanna commented on June 10th 19 at 14:33
everything is on one machine, and the subnet mask to both addresses is 255.255.255.0 - nikita.Stracke commented on June 10th 19 at 14:36
addresses from different subnets. if every address was in his car, the case would be in the absence of a router that connects two subnets into one. but within one machine addresses are supposed to be available. although...
1. what does the command route?
2. what does the command cat /proc/sys/net/ipv4/ip_forward? if 0, then do echo 1 > /proc/sys/net/ipv4/ip_forward and try to open the page again. - shanna commented on June 10th 19 at 14:39

Find more questions by tags Nginx