简体   繁体   English

在同一 docker 主机上的不同容器上托管站点

[英]Hosting site on different containers on same docker host

I am trying to setup multiple containers listening on different ports hosting sites.我正在尝试设置多个容器,侦听不同的端口托管站点。

Example:例子:

example1.com 8080 -> 80 container1 (apache)
example2.com 8081 -> 80 container2 (apache)

What is the correct way to do it?正确的做法是什么?

I have tried http redirects/rewrites (inside containers) but cannot get it to work..我已经尝试过 http 重定向/重写(在容器内),但无法让它工作..

You need a reverse proxy on the server.您需要在服务器上使用反向代理。 I'd go with nginx and configure it similar to here to forward traffic to example1.com to its own port 8080 .我会使用nginx并将其配置为类似于 here将流量转发到example1.com到它自己的端口8080 In Apache this can be done as well.在 Apache 中也可以这样做。 It's called virtual hosts它被称为虚拟主机

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM