nginx - 使用 Docker 和 Nginx proxy_pass 时重启容器

标签 nginx docker proxypass

我有一个 nginx docker 容器和一个 webapp 容器成功运行并相互交谈。

nginx 容器监听 80 端口,并使用 proxy_pass 将流量定向到 webapp 容器的 IP。
upstream app_humansio { server humansio:8080 max_fails=3 fail_timeout=30s; }
"humansio"设置在 /etc/hosts docker 的文件,因为我用 --link humansio:humansio 启动了 nginx . webapp 容器 (humansio) 总是暴露 8080。

问题是,当我重新加载 webapp 容器时,nginx 容器的链接会中断,我也需要重新启动它。有什么办法可以不同地做到这一点,所以当 webapp 容器重新加载时我不需要重新启动 nginx 容器?

--

我尝试过使用公共(public)端口(两者都为 8001)手动连接它们,但由于它们实际上保留了该端口,因此第二个容器也无法使用它。

谢谢!

最佳答案

出于这个原因,我更喜欢直接在主机上运行代理(haproxy 的 nginx)。

但一个选项是“通过大使容器链接”https://docs.docker.com/articles/ambassador_pattern_linking/

https://www.digitalocean.com/community/tutorials/how-to-use-the-ambassador-pattern-to-dynamically-configure-services-on-coreos

关于nginx - 使用 Docker 和 Nginx proxy_pass 时重启容器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28824438/

相关文章:

Apache 代理通行证 : how to preserve original IP address

nginx - 将在Gunicorn上运行的Flask应用程序代理到Nginx中的子路径

javascript - Nginx 重写错误,在 index.php 中包含文件

docker - 来自运行容器的新docker镜像不包含更新的值

postgresql - Postgres Docker : "postgres: could not access the server configuration file "/var/lib/postgresql/data/postgresql. conf": 没有这样的文件或目录"

docker - Docker运行似乎忽略了name参数

Nginx 代理通行证 - 禁用 ipv6

mysql - #1366 - 我的 nginx 服务器中的整数值 : '' for column. 不正确。 (mysql模式)

python - 使用 SSL 时使用 Gunicorn + Nginx 重定向到主页的 Django 管理页面

使用带插值的可变 URL 的 Apache proxypass