samedi 7 mars 2015

Connection refused on ec2 between two servers on same machine

I have an angular app and a mongo app (a REST api). Both are on the same machine. When I try to use an API method, I get



Failed to load resource: net::ERR_CONNECTION_REFUSED http://ift.tt/1webEKM


The angular app is listening on port 3000 (so nginx routes www.mywebsite.com requests to port 3000). This part works. However, the app talks to a server on the same machine on port 1234 (the REST api). This is where it fails.


I'm using nginx to route the requests.



user www-data;
worker_processes 4;
pid /run/nginx.pid;

events {
worker_connections 768;
# multi_accept on;
}

http {

# www.mywebsite.com
upstream api {
#api REST server
server localhost:1234;
}

server {
server_name mywebsite.com;
listen 80;

location / {
#Angular app
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:3000;
}
}



##
# Basic Settings
##

sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;

# server_names_hash_bucket_size 64;
# server_name_in_redirect off;

include /etc/nginx/mime.types;
default_type application/octet-stream;

1,1 Top
##
# nginx-naxsi config
##
# Uncomment it if you installed nginx-naxsi
##

#include /etc/nginx/naxsi_core.rules;

##
# nginx-passenger config
##
# Uncomment it if you installed nginx-passenger
##

#passenger_root /usr;
#passenger_ruby /usr/bin/ruby;

##
# Virtual Host Configs
##

include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}



#mail {
# # See sample authentication script at:
# # http://ift.tt/1izWoAw
#
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen localhost:110;
# protocol pop3;
# proxy on;
# }
#
# server {
# listen localhost:143;
# protocol imap;
# proxy on;
# }
#}

Aucun commentaire:

Enregistrer un commentaire