Node.js - 如何从 url 中删除端口? [英] Node.js - How can I remove the port from the url?

查看:67
本文介绍了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.

这篇关于Node.js - 如何从 url 中删除端口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆