现在是这种情况
1.vps上的博客已经搭建好了,用的是express,后台服务常驻,监听3000端口
2.购买了域名,设置好了解析。
3.通过www.example.com:3000和107.107.107.107:3000(举个例子吧)都能访问主页。
那么怎样做才能 输入www.example.com后就能直接访问主页内容呢?
伊谢尔伦2017-04-17 15:24:44
Listen directly to port 80, or use other software (nginx, apache, etc.) to act as a proxy on port 80
高洛峰2017-04-17 15:24:44
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.
怪我咯2017-04-17 15:24:44
means that my blog also uses express and listens to port 3000. It can be used directly after domain name resolution. . .
http://charten.ml
伊谢尔伦2017-04-17 15:24:44
Thank you for the invitation.
Install Nginx, and then use proxy_pass
to reverse proxy to localhost:3000
.
PHPz2017-04-17 15:24:44
Use nginx to listen to port 3000 and forward the request to your server
大家讲道理2017-04-17 15:24:44
The answer has been mentioned above. I think iptable port forwarding should work without nginx. You can try it!
ringa_lee2017-04-17 15:24:44
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?
迷茫2017-04-17 15:24:44
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