Elasticsearch : connect to a remote server via. SSH (Node JS) - node.js

I'm currently using Node's [elasticsearch][1] package. Until now, I connected to the ES instance in the following way.
let esClient = new elasticsearch.Client({
host: '127.0.0.1:9200',
log: 'trace'
});
Now, I've installed ES on a remote Amazon EC2 Linux server by tunneling through SSH using a key file.
I've done the basic ES installation and setup on that server. Tested it as well, and it runs properly.
I've now deployed my Node project on a Server X (EC2 - Ubuntu server).
And Elasticsearch is on Server Y(EC2 - Amazon Linux server).
Apart from specifying the IP in the host parameter what else do I need to connect to ES running on Server Y from Server X?

You have to make sure you have the port (9200) open in Amazon's Security Group settings.

Related

connect node app running in windows to redis running in wsl

i have setup wsl in my windows server machine and started the redis service there.
from the windows command prompt i can use wsl redis-cli and run the redis commands.
but my node application is not able to detect the redis inside wsl. i am using redis in my node project.
is there any third party module i need to add to able to connect, this answer showed to add it in python.
the wsl's redis port was readily available.
const client = redis.createClient(); just kept the createClient() config blank and it connected.

can not connect to postgres db from node server

I want to connect my apps nodejs using node-posgres to PostgreSQL. My apps in linux server and my postgresql in another linux server by 176.9.154.123 IP.
this is my error:
this is my pg_hba.conf:
host all all 176.9.154.123/32 trust
i can solve this problem by add this line to postgressql.conf:
listen_addresses = '*'

Connecting with server linux ubuntu system in Django

I have created a sample Django admin page which will do some basic insert update in my local machine.
Now I have installed Django 1.7.7 and python 2.7 in Linux Ubuntu server machine and it has firefox installed.
Is it possible, to connect with the server through any tunnel, so that from my system by python manage.py runserver localhost:port?
So that I can actually connect the server computer and can have the admin console page in server which I can access from my local system.
I know that I can do that by public IP but I dont know the server public ip address nor the domain name.
So any solution for this
The development server listens to 127.0.0.1 by default. In order to connect to your development server from another machine, you need to listen to all IP addresses. Try running the development server by
python manage.py runserver 0.0.0.0:8000
and connect to it from your other PC using:
http://server_ip_address:8000

Strange behaviour of Mean.io on Azure VM‏

I created an Azure virtual machine with Ubuntu 14.04 LTS OS.
I installed a mean.io application version 0.3.3, on this virtual machine, with nginx that proxy the requests in the http port 3000 over the port 80.
I opened one endpoint in azure portal, for the TCP protocol on private port 3000 and public port 80.
I installed the latest version of node on Azure VM.
The database (mongoDB) is hosted on compose.io.
With pm2 (https://www.npmjs.org/package/pm2) I created a daemon that run the application.
All apparently works fine: the cpu was with no load and the memory was empty (only 100MB).
But after a period, node.js cannot process the request.
I have tried to do a 'curl' in localhost 3000 but i dont have any response.
The problem persists only in Azure VM: I tried the same application, with the same configuration, on my dev machine (ubuntu 14.04 desktop), and on Digital Ocean (another distro of ubuntu 14.04 server) and all works fine without problem.
Can you help me to find the problem?
I have tried to dockerize all infrasctructure, in the same machine (a CoreOS vm on azure):
1 container with mean app,
1 container with MongoDB,
the problem still persisted!!!
finally, i have found the solution: keep the connection to MongoDB alive.
i have modified the server.js file from the mean app in this mode:
var options = {
server: {
socketOptions: { keepAlive: 1 }
}
};
var db = mongoose.connect(config.db, options);
In this mode the connection still alive and the problem was solved.

How should my local server communicate with an EC2 server?

I have a node.js server running on ec2. I'd like for that server to automatically push data to another node.js server that is running on my laptop.
What is the best way to do something like this?
You could use a service like showoff.io to create an entry point to access your local laptop, or you could just create an SSH tunnel by running this command on your laptop:
ssh -R port:localhost:remoteport ec2-host
That will allow port on the loopback interface of your EC2 server to connect to remoteport on your laptop.
Then just modify your code to connect to the node.js program running on your laptop via the IP of 127.0.0.1 and port of port.
You could have the EC2 node.js call a function from the local node.js, and pass the data as variables

Resources