I need to connect websockets with normal sockets, websockify looks seem the answer, but I donĀ“t really understand what do I need to do whit this info: https://www.npmjs.com/package/node-websockify, do I need to create a Node js server, or only run into my page??
The websockify people were nice enough to create a node js version located here -
enter the command
node websockify.js [--web web_dir] [--cert cert.pem [--key key.pem]] [source_addr:]source_port target_addr:target_port
so the command:
node websockify.js --web web 127.0.0.1:9988 192.168.1.40:5432
would start a "relay" from the target address (the server you don't have access to) to your own proxy server (server you do have access to - where you are proxying the websockets from the vnc server to TCP, which enables you to view the connection via web browser. With this proxy comes a
built-in web server to "serve" the view. so the web option is the location of said HTML, CSS, and JS files to display. If you copy the files from the app directory css-files and the vnc file from the root with all dependencies, you can then view the files by navigating to the source IP address and port and that should take care of it.
Related
I think I'm doing something completely the wrong way.
I have an Nodejs server running that read in a DB and serve with express some data via http locally (it has to only be accessed locally). It sends the data on localhost on some port (8080 for example). Then I have an angular app on the server that get these datas from an http request on localhost:8080 and display them. The angular app runs locally on localhost:4200.
I was building the entire stuff on my computer and that was working perfectly (I have no problem with CORS). Then I deployed it on a server, and I accessed it via ssh port forwarding. Basically I forward localhost:4200 on the server via ssh on my local computer on localhost:8090.
And my problem is that, when loading and executing the angular app in my browser via port redirection, it's doing a get request to localhost:8080. So it's trying to communicate with the localhost it's running on, which is the client itself.
If you understood my spaghetti situation, there is actually a dirty solution : redirect localhost:8080 on the server to localhost:8080 on the client.
Is there any way to do the get request server side and not in the client's browser so that localhost correspond to the server? Is there a better way to do what I'm trying to do?
I can sum up by : How can you access another local service on localhost on the server with angular app since it executes in the client browser and localhost will refer to client localhost.
Try to use any web server (such as nginx or apache2 or etc.) in your server and make use of proxy and reverse proxy with your node application, it will work
angular2-router-and-express-integration
I have got 2 applications:
Nodejs application and Angular application.
I would like to host them both on the same Linux server (Linode).
Also I have a DNS record for example : forexample.com.
I would like that when I navigate to api.forexample.com it will navigate inside the linux server to the Angular application, and I should see the angular pages.
The nodejs application is a API application which I would like other people to make all the HTTP requests to api.forexample.com/api.
So the question is how to make the navigation inside the linux server?
Generally speaking to run multiple applications on a server. First you need to add an A record on your DNS record for api.forexample.com
Then you can use nginx to handle the two applications. The way it will work is that each application will run locally on its own port and nginx will handle the url you provide and map it to the appropriate application. Check out this tutorial: Configure Nginx as a web server
In your situation you could serve the angular app from the node application.
Check this too: How to serve an angular2 app in a node.js server
I am simply a beginner at NodeJs. I have a client's Ionic project.
He has sent me
Server Access FTP:
IP, user and pass
and has said, if any server side changes then to be done on server.
app.js file for socket and server side component is in /usr/www
Now i can't find any 'app.js' consisting of node commands in the project. There is an app.js in www/ directory but there is not node command inside. How to access server and where to use the IP, user, pass.
Please explain if you know the answer. Considering me totally nil at node.js and express.js
You can use node-ftp as a FTP client. It is a module for node.js which will provide an interface to communicate with the FTP server. You can refer this link to get more information about node-ftp.
So I created a node app that uploads pictures and the app works locally, I can upload stuff from all of my home devices and they end up in my designated upload folder. Next thing is to go global, so I moved the app to an FTP server and... I don't know how to start it. I can't go
node server.js
like I do on my PC in cmd, can I? I open my index page but when I upload something I get: Server responded with 0 code. Just like when I open my index.html without starting the node app trough cmd on my PC. I'm a front-end guy and I don't know almost anything about servers and I've searched quite a bit around the internet, but to little avail.
One fairly quick way to get this set up would be to sign up for a virtual server on Amazon using their EC2 server instances. Just choose the basic instance (whichever one is free for the first year) and then install Node and run npm install on your root directory once you have uploaded the files. Also if you are going to want this site accessible with your own domain you will have to set up an elastic IP address also available via Amazon (AWS). Furthermore if you want to have your url accessable via the standard port 80 (meanning that you don't have to type your url:[port number]/path then you might want to look into setting up a reverse proxy using something like nginx.
I know this sounds like a lot and i won't lie to you this is kind of complicated but there is a lot more to getting a node application up an running that you might expect.
Before a node app can run on a server you need to make sure that:
Node is installed
npm install has successfully run / or all dependencies must be transferred to the app directory in the right place
The port of the node server should be reachable, so the routing must be set up correctly.
Also, you can't start a program from an ftp prompt usually.
Is this scenario possible, and if not, how to make it possible?
Assume I have nodejs running on port 8080. I also have Apache running on port 80.
On the nodejs port, I have express with socketIO.
On Apache, I have a index.html webpage with a textbox with a submit button that includes "socket.io-client.js". Entering a message in the textbox and hitting submit would pass the message over to the nodejs on port 80 that would effectively broadcast the message to all other users who have their page open at the index.html hosted on the apache.
From the examples I've seen so far, socketio, the webpage, express, all have to reside with wherever node is, so that the index.html page can include the script "/socketio/socket.io.js". Is there some way I could include the socket.io.js script hosted on a server outside of nodejs? If any example or configuration available that would be needed for this to work would be helpful.
You can simple include socket.io.js in your index.html by specifying node.js port in srcipt URL like:
<script src="http://your.host:8080/socket.io/socket.io.js"></script>
If you are running node.js on same machine as Apache, you could check out this link, it explains how to redirect any connections to node.js for some "folders" within url path.
You will have to run node.js on another port, and then using .htaccess redirect connection to node.js for specific folder within url path.