Home  >  Q&A  >  body text

linux - 直接输入一个域名,如何访问指定的端口

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

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

大家讲道理大家讲道理2743 days ago899

reply all(10)I'll reply

  • 伊谢尔伦

    伊谢尔伦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

    reply
    0
  • 高洛峰

    高洛峰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.

    reply
    0
  • 怪我咯

    怪我咯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

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-17 15:24:44

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

    reply
    0
  • 天蓬老师

    天蓬老师2017-04-17 15:24:44

    nginx reverse proxy

    reply
    0
  • PHPz

    PHPz2017-04-17 15:24:44

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

    reply
    0
  • 大家讲道理

    大家讲道理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!

    reply
    0
  • ringa_lee

    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?

    reply
    0
  • 迷茫

    迷茫2017-04-17 15:24:44

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

    reply
    0
  • 迷茫

    迷茫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

    reply
    0
  • Cancelreply