Issue
I am trying to run my node.js application on port 3000. I am using nginx as a reverse proxy server to communicate with node.js internally. Nginx is working fine but node.js server is also available if I try to run it with the server ip and port.
I want that my node.js server is not accessible via browser and it only communicates via nginx server internally.
I am running my node server on http and https on nginx server. Both the node server and the nginx server are running on a vm with CentOS(Linux). I want that the node.js server should not be accessible outside the vm even through any browser on my windows laptop neither from the outside world
Can someone kindly guide me about how to achieve it?
Solution
I want that my node.js server is not accessible via browser and it only communicates via nginx server internally.
I assume by "via browser", you mean via other users, and not a browser on localhost. I also assume you're using the built-in HTTP/S server, either directly or via something like Express. Finally, I assume Nginx is running on the same host. If these assumptions aren't correct, you should edit your question to clarify, and show some code.
Now, when you call .listen()
to start the server, there are optional parameters you can pass to set the port and bind host. For example, if I did this:
server.listen(3000, '127.0.0.1', ...);
This would start a server that listens on port 3000
, but only accepts connections when made from localhost
, 127.0.0.1
. This means that anything on that machine can connect to :3000
and make requests, but requests from other hosts won't work.
Answered By - Brad Answer Checked By - Marilyn (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.