最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Configure nginx-proxy on custom server to route to proper container - Stack Overflow

programmeradmin3浏览0评论

I have a server running nginx-proxy in a Docker container on port 81, i'm using nginx-proxy:

docker run -d -p 81:80 --name nginx-proxy -v /var/run/docker.sock:/tmp/docker.sock:ro nginxproxy/nginx-proxy

On this same server, I tried to launch a Chronograf container with the following commands. This are my two tries:

docker run -d -p 8889:8888 --name chronograf -e VIRTUAL_HOST=my.custom.server -e VIRTUAL_PATH=/my_chronograf/ -e VIRTUAL_DEST=/ chronograf

docker run -d --name chrono -e VIRTUAL_HOST=my.custom.server -e VIRTUAL_PATH=/my_chronograf/ -e VIRTUAL_DEST=/ -e VIRTUAL_PORT=8888 chronograf

However, it doesn't work with any of them and I can't access Chronograf through:

  • :81/my_chronograf.

What modifications do I need to make to my Chronograf docker run command so that it works with the nginx-proxy on port 81 and is accessible at my.custom.server:81/my_chronograf?

I have a server running nginx-proxy in a Docker container on port 81, i'm using nginx-proxy:

  • https://github/nginx-proxy/nginx-proxy/tree/main

docker run -d -p 81:80 --name nginx-proxy -v /var/run/docker.sock:/tmp/docker.sock:ro nginxproxy/nginx-proxy

On this same server, I tried to launch a Chronograf container with the following commands. This are my two tries:

docker run -d -p 8889:8888 --name chronograf -e VIRTUAL_HOST=my.custom.server -e VIRTUAL_PATH=/my_chronograf/ -e VIRTUAL_DEST=/ chronograf

docker run -d --name chrono -e VIRTUAL_HOST=my.custom.server -e VIRTUAL_PATH=/my_chronograf/ -e VIRTUAL_DEST=/ -e VIRTUAL_PORT=8888 chronograf

However, it doesn't work with any of them and I can't access Chronograf through:

  • http://my.custom.server:81/my_chronograf.

What modifications do I need to make to my Chronograf docker run command so that it works with the nginx-proxy on port 81 and is accessible at my.custom.server:81/my_chronograf?

Share Improve this question edited Mar 31 at 8:57 Avión 8,41514 gold badges71 silver badges112 bronze badges asked Mar 31 at 8:56 Aitzol Soto ZubizarretaAitzol Soto Zubizarreta 211 silver badge2 bronze badges New contributor Aitzol Soto Zubizarreta is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
Add a comment  | 

1 Answer 1

Reset to default 0

From the first link that you provided i read that for nginx to be able to proxy requests to other containers on the same network, the cronograph container must use the --expose flag to expose the port, not the -p flag.

And the containers must be on the same network too. In your case it looks like you are using the default bridge network for both the containers so it should work just replacing the -p with the --expose flag. Let me know

发布评论

评论列表(0)

  1. 暂无评论