I have hosted my spring boot application on AWS elastic-beanstalk, but when I try to access it with the public URL, it is gives me 502 Gateway Error. In the log, I can see the below error: 2017/08/05 20:10:33 [error] 22965#0: *157 connect() failed (111: Connection refused) while connecting to upstream, client: XXX.68.241.XXX, server: , request: "GET /swagger-ui.html HTTP/1.1", upstream: "http://127.0.0.1:5000/swagger-ui.html", host: "XXXXXXXX-env.XXX.us-west-2.elasticbeanstalk.com"
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
upstream tomcat_servers{
ip_hash;
server 127.0.0.1:5000;
keepalive 256;
}
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
}