如何将在特定端口号上运行的服务映射到 Ubuntu 上的别名?

发布于 2024-07-21 04:10:30 字数 321 浏览 11 评论 0原文

如何将在特定端口号上运行的服务映射到 Ubuntu 8.10 上的别名?

例如,我有一个网络服务,我可以这样访问:

http://localhost:3000/

但我想这样访问:

http://myservice/

我只想从同一台机器访问该服务。

我运行的是 Ubuntu 8.10,一开始我以为我可以修改 /etc/hosts 文件,但我现在明白我不能包含端口号。 我还查看了 /etc/services 文件,到目前为止没有任何运气......

How I can map a service running on a specific port number to an alias on Ubuntu 8.10?

For example, I have a webservice which I can access like this:

http://localhost:3000/

But I want to access like this:

http://myservice/

I only want to access the service from the same machine.

I am running Ubuntu 8.10 and I thought at first I could modify the /etc/hosts file but I now understand I cannot include port numbers. I also looked at /etc/services file without any luck so far...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

妳是的陽光 2024-07-28 04:10:31

“http”的默认端口是 80,因此您需要 root 权限才能执行此操作。 您可以采取多种途径:

  • ssh -l root -L 3000:localhost:80 localhost
  • netcat 也应该能够做到这一点
  • 使用防火墙转发数据包

The default port for "http" is 80, so you need root privileges to do this. There are several routes you can take:

  • ssh -l root -L 3000:localhost:80 localhost
  • netcat should be able to do this, too
  • Use the firewall to forward packets
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文