linux - 直接输入一个域名,如何访问指定的端口
大家讲道理
大家讲道理 2017-04-17 15:22:44
0
10
902

现在是这种情况
1.vps上的博客已经搭建好了,用的是express,后台服务常驻,监听3000端口
2.购买了域名,设置好了解析。
3.通过www.example.com:3000107.107.107.107:3000(举个例子吧)都能访问主页。

那么怎样做才能 输入www.example.com后就能直接访问主页内容呢?

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(10)
伊谢尔伦

Listen directly to port 80, or use other software (nginx, apache, etc.) to act as a proxy on port 80

小葫芦

Thank you for the invitation.
This question should be available on Baidu, keyword:

  • apache port forwarding

  • nginx port forwarding

In addition, if you are not using port 80, you can directly set up listening port 80.

刘奇

means that my blog also uses express and listens to port 3000. It can be used directly after domain name resolution. . .
http://charten.ml

伊谢尔伦

Thank you for the invitation.
Install Nginx, and then use proxy_pass to reverse proxy to localhost:3000.

Peter_Zhu

nginx reverse proxy

PHPzhong

Use nginx to listen to port 3000 and forward the request to your server

大家讲道理

The answer has been mentioned above. I think iptable port forwarding should work without nginx. You can try it!

左手右手慢动作

The default HTTP port is 80. When the domain name does not specify a port, port 80 is used
So you can just listen to 80

——Or do you mean that your server cannot use port 80, or it is occupied by other processes?

迷茫

Just listen to port 80, which is the default port number of HTTP

迷茫

Http accesses port 80 by default, there are two solutions

  • One is to directly access the port number. For example, for port 8080, use hello.com:8080 to access

  • Another method that a friend mentioned before is to set up a reverse proxy, such as the famous nginx and apache.

From your question, I think you can take a look at the reverse proxy mode of nginx, search it on Baidu or Google:

Nginx reverse proxy

There are usually many answers

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!