【问题标题】:how to connect each port with sub domain in apache如何将每个端口与apache中的子域连接起来
【发布时间】:2018-10-26 12:56:32
【问题描述】:

我想将每个子域连接到另一个端口。

例如,如果我有 example.com 域,我想这样做

apple.example.com with 127.0.0.1:80 (Apache Port)
grape.example.com with 127.0.0.1:3000 (Node.JS App Port)
orange.example.com with 127.0.0.1:4000 (Another App Ports..)

我已经在我的域公司中创建了子域,它适用于 80 端口。但它无法连接其他端口,如 3000 或 4000。

解决此问题的最佳方法是什么?当我在google上搜索时,有人说我应该在Apache中使用Virtual Host功能,但有人说因为性能问题,这不是一个好方法。

【问题讨论】:

    标签: node.js apache networking port


    【解决方案1】:

    我自己解决了这个问题。这是解决方案。

    1. 进入 /etc/apache2/sites-available 目录

    2. 使用 conf(或域)ex) test.example.com.conf 创建以您的子域命名的文件

    3. 在配置文件中

      <VirtualHost *:80>
          ServerName test.example.com
      
          ProxyPass / http://localhost:3000/
          ProxyPassReverse / http://localhost:3000/
      
      </VirtualHost>
      

    例如在 3000 中放置我要连接的端口。

    1. 打开终端获取root权限

    2. 输入命令a2ensite Your_Domain

    3. 使用此命令重新加载 apache2 systemctl reload apache2

    完成,子域(或您的域)将使用内部端口,但外部连接将显示为 80 端口。

    【讨论】:

      猜你喜欢
      • 2023-03-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-02
      相关资源
      最近更新 更多