【发布时间】:2020-03-12 15:49:14
【问题描述】:
首先是一些上下文
- 我们有一个在 Azure 上运行的 Ubuntu Server 18.04 LTS 服务器
- 我们公司的安全策略只允许通过 HTTP/HTTPS 访问端口 80 和 443
- 在其他端口上运行的任何应用程序(例如 Jenkins 或 NodeJS 的应用程序)都应通过 Apache 使用反向代理
- 同一台服务器已经在端口 8080 上运行了 Jenkins,并且 Jenkins 本身可以配置为使用他们所谓的“--path”参数运行,这使得它可以通过 URL http://localhost:8080/jenkins 访问,因此反向代理非常简单配置为“/jenkins”的任何内容都可以传递给http://localhost:8080/jenkins,当前的 Apache 配置(适用于 Jenkins)如下:
# Jenkins
ProxyPass /jenkins http://localhost:8080/jenkins nocanon
ProxyPassReverse /jenkins http://localhost:8080/jenkins
ProxyRequests Off
AllowEncodedSlashes NoDecode
<Proxy http://localhost:8080/jenkins*>
Order deny,allow
Allow from all
</Proxy>
我们面临的问题
因此,为了运行 OpenTest,我们必须将其安装为 npm 包,然后可以通过运行 opentest server 命令执行,默认情况下它将在端口 3000 上启动应用程序 http://localhost:3000 但可以更改首选端口以及通过配置https://getopentest.org/reference/configuration.html#server-configuration
问题是我们需要重新路由任何东西,比如说将“/opentest”转到 opentest 服务器应用程序,但这不适用于所有静态资产、api url 等......因为应用程序是只是在端口 3000 http://localhost:3000 上运行,但似乎没有像 Jenkins 的“--path”这样的东西,所以我们不能只模仿我们为 Jenkins 提供的相同反向代理;我们的想法是在路径“/opentest”中使用 opentest,例如 http://localhost:3000/opentest。
我们找不到任何 OpenTest 配置可以让我执行http://localhost:3000/opentest 之类的操作,而且我们是 pm2 的新手,所以我们无法判断是否可以使用 pm2 以在“路径”或某种“本地已知应用程序域”中运行 OpenTest 应用程序,我们可以使用它来将反向代理重新路由到。
欢迎任何想法、想法、解决方法或解决方案;我们可能在这里采取了错误的方法,因此我们也将感谢您在这方面的任何见解。
谢谢!
【问题讨论】:
标签: node.js apache reverse-proxy pm2 opentest