Node.js - 如何从 url 中删除端口?

问题描述:

我使用 node.js 和 socket.io.

I use the node.js and socket.io.

我的应用程序在端口 3000 上运行.应用程序从 url 开始:mydomain.com:3000/

My application runs on the port 3000. The application starts from from the url: mydomain.com:3000/

我想从 mydomain.com 运行应用程序 - 我想从 url 中删除端口.

I want to run the application from mydomain.com - I want to remove the port from the url.

在哪里以及如何设置此设置?

Where and how can I set this setting?

找到你的 server.listen 调用并将端口从 3000 更改为 80.不要忘记您必须使用 CAP_NET_BIND_SERVICE 功能运行程序(请参阅 capabilities(7) 了解详细信息)才能绑定到 Linux 系统上小于 1024 的端口.root 权限将包含此权限和其他权限.

Find your server.listen call and change the port from 3000 to 80. Don't forget that you have to run the program with the CAP_NET_BIND_SERVICE capability (see capabilities(7) for details) in order to bind to ports less than 1024 on Linux systems. root privilege will contain this, and other, privileges.