【问题标题】:two docker app container on one nginx一个 nginx 上的两个 docker app 容器
【发布时间】:2015-12-29 16:57:12
【问题描述】:

我尝试为应该由 hhvm 提供支持的 2 个 Web 应用程序提供服务。构建一个包含 nginx 和 default.conf 的 docker 镜像很容易。但是现在我将在哪里获得n 应用程序作为微服务,我想测试它们并共享 nginx 容器,因为我继续与 DB 等其他人一起使用,例如

那么当使用 hhvm 从外部访问 nginx 时,我是否也必须在此映像上提供 hhvm?或者我可以将它引用到已经提供 hhvm 的 debian 吗?然后,我可以像这样存储nginx.conf

upstream api.local.io {
   server 127.0.0.1:3000;
}

upstream booking.local.io {
   server 127.0.0.1:5000;
}

如何为此设置合适的 nginx 容器?

【问题讨论】:

标签: docker nginx kubernetes containers hhvm


【解决方案1】:

是的,您可以创建另一个带有nginx.conf 的 nginx 容器,其配置与此类似:

upstream api {
   # Assuming this nginx container can access 127.0.0.1:5000
   server 127.0.0.1:3000;
   server server2.local.io:3000;
}

upstream booking {
   # Assuming this nginx container can access 127.0.0.1:5000
   server 127.0.0.1:5000;
   server server2.local.io:5000;
}

server {
    name api.local.io;
    location / {
        proxy_pass http://api;
    }
}

server {
    name booking.local.io;
    location / {
        proxy_pass http://booking;
    }
}

【讨论】:

  • 好的,我的 hhvm 容器中有这个,里面有这一行:- ./hhvm/application:/usr/share/nginx/html 我如何告诉 nginx 容器,嘿,这个站点的端口 80 看看 127.0.0.1:9000,因为我暴露了用于 nginx 的 hhvm 端口 9000
  • 这对我帮助很大。谢谢。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2022-01-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-03-17
  • 1970-01-01
相关资源
最近更新 更多