【问题标题】:Node JS & Apache HTTP节点 JS 和 Apache HTTP
【发布时间】:2018-09-28 17:01:52
【问题描述】:

需要有关在服务器中设置 Web 应用程序和 REST api 的帮助/建议。

目前有如下 3 个应用程序

  1. 用户 Web 应用程序 - 在 node.js 上运行 - 端口 3389 / 通用反应应用程序
  2. 管理 Web 应用程序 - 在 apache 上运行 - 端口 8080 / laravel
  3. 用于用户应用程序的 Rest Api - 在 apache 上运行 - 端口 8080 / laravel

目前我们加载如下应用程序

用户应用程序:- www.xyz.com:3389 万维网。 xyz .com:3389/帮助 万维网。 xyz .com:3389/房东介绍

管理应用程序:- www.xyz.com/app/admin

REST API 路由:- 获取http://xyz/app/country?id=1 获取http://xyz/app/location

为了加载没有端口号的用户应用程序,我们尝试在 apach conf 中设置代理传递,如下所示

代理密码http://127.0.0.1:3389/ ProxyPassReverse http://127.0.0.1:3389/

代理通行证http://127.0.0.1:8080/app/admin/ ProxyPassReverse http://127.0.0.1:8080/app/admin/

现在重启 apache 后,我们可以在不使用端口号的情况下访问用户应用程序,但无法访问管理应用程序,而且我们需要知道如何从客户端代理传递 rest API。

【问题讨论】:

    标签: node.js apache proxy


    【解决方案1】:

    您可以使用或创建虚拟主机,在 Apache HTTPD 中基本上是这样的:

    <VirtualHost *:80>
    ServerName xyz.com
    Redirect / https://example.com/
    </VirtualHost>
    
    <VirtualHost *:443>
    ServerName example.com
    SSLEngine on
    SSLCertificateFile /path/to/cert.pem
    SSLCertificateKeyFile /path/to/key.pem
    ErrorLog /path/to/logs/publicaname.example.com-ssl-error.log
    CustomLog /path/to/logs/publicaname.example.com-ssl.log combined
    
    ProxyPass /api/input http://127.0.0.1:8080/api/input
    ProxyPassReverse /api/input http://127.0.0.1:8080/api/input
    </VirtualHost>
    

    【讨论】:

    • 我们已经做到了,在帖子中也提到了。一个用户应用程序可以工作,但另一个不能。
    • ' ProxyPass 127.0.0.1:3389 ProxyPassReverse 127.0.0.1:3389 ProxyPass 127.0.0.1:8080/app/admin ProxyPassReverse 127.0.0.1:8080/app/admin ' 这不起作用。用户应用程序打开正常,即 www.xyz.com:3389 但管理应用程序:www.xyz.com/app/admin 没有启动
    猜你喜欢
    • 2022-01-18
    • 1970-01-01
    • 1970-01-01
    • 2013-03-15
    • 2016-06-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多