Not able to get client IP address on server in NodeJS - javascript

I am working on nodeJS project in this project I want to get client IP address. For this I am using public IP package, I’m using
the following code, and installed the package accordingly.
‘npm install --save public-ip
and following code
publicIp.v4().then(ip => {
});’
The above code is working fine locally, but when deployed on the server(AWS server), it’s giving the AWS server IP.
Help me resolve the issue.

Related

I want to deploy Node.js & React.js projects in same domain and server

As per my Title, I want to deploy Node.js & React.js projects in the same domain and server.
Basically, I want to host the application on cloudways server. https://www.cloudways.com/
I try to host there but due to the same domain action, it is not working as working in the local environment.
Front-end screenshot with package.json script structured(React.js): https://prnt.sc/xT4NAPxt0S99
Back-end screenshot(Node.js): https://prnt.sc/mSg_H4O6prF0
The given screenshot is from a local machine.
As you see here https://prnt.sc/xT4NAPxt0S99 we are using npm run build and after doing the build, we move that folder to the server folder and run npm i && nodemon index.js. It is working well in a single domain or IP in the local server well. But when I do the same process on a live server, it is not working.
Why I am using cloudways server?
For this, I don't need to install and set up MySQL, Node modules, PHP, and other things. Cloudways is doing all things when we create a cloud server.
npm i don't need to run this company on a server.

How connect to Html page with node.js server and aws virtual machine

I'm trying to install a node.js server for a sentiment analysis service with my Twitter account that retrieve the tweets on my profile and provides a statistical output and saves them on a Mongo db istance.
I have uploaded my node.js code on an AWS virtual machine with an public IP address and with the permission to create an endpoint with HTTP and HTTPS protocols.
I have installed successfully the node.js code on AWS virtual machine with Windows Server 2019 OS, with the npm install -g -n command with 0 dependencies errors, and when I try to connect to the AWS virtual machine with http://ip_public_address:8080 I get the error "impossible to connect - err-connection_timeout".
This is the link to the github project that I need to install and to work on AWS virtual machine:
https://github.com/thisandagain/sentiment
Maybe I am confused about how to connect with the index.html page via AWS virtual machine and I don't know if this page must be retrieved with a IP public address or localhost parameter and what is required, at node.js level code, in order to enable the AWS virtual machine to respond to my browser with the content of index.html page.
Please can you give me advices about to implement successfully this project?
Thanks
Filippo
You don't mention security groups in your question at all, so the likely cause is that you never opened port 8080 in the security group assigned to the EC2 instance. You may also need to open that port in the Windows firewall on that server.

Reg: Installation of FHIR 5.2.0

I am very new to the hapi-fhir, I have download source (hapi-fhir-5.2.0-standard-distribution) from below link. I am trying to deploy the server on localhost.
https://github.com/hapifhir/hapi-fhir/releases/tag/v5.2.0
OS: ubuntu 16.04
java version: 1.8.0_275
Please help me with deployment procedure ?
If you just want to play with a FHIR server, I'd recommend learning the resources, search params, etc. using a public reference server, e.g. http://hapi.fhir.org/baseR4/
If indeed you need to get started locally, try the Docker installation of the jpa server: https://github.com/hapifhir/hapi-fhir-jpaserver-starter#running-via-docker-hub
The CapabilityStatement will tell you what the server can do: http://localhost:8080/fhir/metadata
To search a resource: http://localhost:8080/fhir/ (e.g. http://localhost:8080/fhir/Patient)
The server will be empty, so you'll need to POST/import data.

how can I connect to a http://localhost:4200 using browser which is a aws ec2

I am learning node.js in an online course to build up a web server and app
before the teaching started, the teacher told me to set up your coding environment, and it got a direction to told me what to do step by step.
Because I using Chromebook, So I started an aws ec2 serve which is ubuntu 18.04 and using cloud9 for my ide
I installed node.js successful on the ec2
And the direction told me to type on those on the terminal
git clone https://github.com/OpenClassrooms-Student-Center/5614116-front-end-app.git frontend
You can then do the following:
cd frontend
npm install
ng serve
This will install all the dependencies needed by the front end app and will launch the development server. Now, if you navigate to http://localhost:4200 , you should see the following (assuming you've followed the steps above successfully):
the direction say if I successfully followed the step, will see something on http://localhost:4200
On the terminal, at last show me
ℹ 「wdm」: Compiled successfully.
But how can I connect to http://localhost:4200 which was an ec2?
I tried using IP:4200, the browser keeps on loading the page and nothing shows up on the browser
----------------------------------------
I found out that the program that teacher gave me to install set the URL to http://localhost:4200
because cloud9 says the program was running, but running at a URL call http://localhost:4200
what should I do?
Localhost refers to your local machine. But as mentionedd that your node.js running on ec2 and want to connect to it from your browser, get the IP of the ec2 and type in your browser- IP:4200
And it should work
The only problem here is you have to add port 4200 in your aws ec2 instance security group to allow inbound traffic.
STEPS:
1. Go to your EC2 instance.
2. Click security group from Description below.
3. Click Inbound then Edit.
4. Click Add Rule
5. Select Custom TCP , Port - 4200 , IP - 0.0.0.0/0
6. Then SAVE.
After that try <EC2-IP:Port> in your browser it will work fine.

How to change local ip to server ip in order to use Node.js

Yesterday, I registered a new account at digitalocean.com in order to use a server. What I want to do is use Node.js for testing purposes. So I made a new droplet with the Ubuntu OS and later on, I used FileZilla to find the www file and upload html, js, css with node_modules files/folders. I installed node package manager, mongodb, mongoose and express. But the problem for now is socket.io can't be found. I changed local ip
http://127.0.0.x./socket.io/socket.io.js
to
http://178.62.220.194/node_modules/socket.io/socket.io.js
I will upload more info soon. Any help is appreciated.

Categories