R
R
Roman Kornilov2020-02-08 02:03:37
Nginx
Roman Kornilov, 2020-02-08 02:03:37

LEMP Stack - how to socket.io?

Hello comrades, I ask for a little help because I tried to understand this issue, but after reading various guides I realized that they are not quite suitable for my understanding, I ask you to maybe point me in another direction for solving this problem, or simply explain without much detail how it can be implemented.

Essence:
There is a configured vds + ubuntu + lemp stack (domain + ssl) in general, a simple standard web server on which there can be anything from cms to just any static.

And then I wanted to implement one thing, for example, in the domain.com/app directory there are two html files (the first: buttons for sending commands and requests to socket.io | second: which receives this request in real time and, for example, executes some kind of js)

(foreword, I just started getting acquainted with node.js and only recently set up a web server for the first time, so I ask you not to scold me for illiteracy in some matters)

So: can I, without affecting the work of the web server, give nginx static these two files) and use node.js + socket.io to transfer data, without implementing a server on node.js (since there is nginx that can give html files), because looking at different guides I saw there at least require http, but either I I don’t understand something, but as if the server already exists.

PS: And is the installed socket.io package already a server? , or connect http in server.js is a mandatory rule for socket.io

In general, I apologize if I incorrectly asked a question somewhere, but I tried to roughly describe the task, I will be very grateful to you for your time and attention to this issue, Thank you very much!

PSS: I wrote a question with eyes glued together, so I could ramble somewhere, sorry), thanks again!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stalker_RED, 2020-02-08
@Roman_Glitch

In the nginx config, specify that you want to give everything as static, except for some specific addresses that are through the node.
https://www.nginx.com/blog/nginx-nodejs-websockets...
https://nginx.org/ru/docs/http/websocket.html

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question