[英]Docker - how to expose port thru jwilder nginx-proxy?
My problem is similar to this one , which is apparently unsolved to this day:/ I was following this tutorial to setup my Theia IDE, the IDE is working but I want my 8080 port to be open for testing out the node.js backend I host on Theia IDE 使用终端。 这是我用于设置开放端口等的 docker-compose 文件:
version: '2.2'
services:
eclipse-theia:
restart: always
image: theiaide/theia:latest
init: true
environment:
- VIRTUAL_HOST=mydomainhere.com
- LETSENCRYPT_HOST=mydomainhere.com
version: '2'
services:
nginx-proxy:
restart: always
image: jwilder/nginx-proxy
ports:
- "80:80"
- "443:443"
- "8080:8080"
volumes:
- "/etc/nginx/htpasswd:/etc/nginx/htpasswd"
- "/etc/nginx/vhost.d"
- "/usr/share/nginx/html"
- "/var/run/docker.sock:/tmp/docker.sock:ro"
- "/etc/nginx/certs"
letsencrypt-nginx-proxy-companion:
restart: always
image: jrcs/letsencrypt-nginx-proxy-companion
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
volumes_from:
- "nginx-proxy"
如果我在 eclipse-theia docker-compose 文件中添加expose: - "8080"
,我会返回 502 错误......所以我猜这不是 go 的方法。 我还尝试运行 netcat 来检查端口 8080 是否已打开。
更新当我收到 502 错误时,我在日志中收到以下错误: [error] 136#136: *21 no live upstreams while connecting to upstream
如果我添加ports: - "8080"
反而我收到一个 HSTS 错误..
更新 2
我按照以下答案的建议尝试了以下配置:
version: '2.2'
services:
eclipse-theia:
restart: always
image: theiaide/theia:latest
init: true
environment:
- VIRTUAL_HOST=mysubdomain1.domain.com,mysubdomain2.domain.com
- VIRTUAL_PORT=80,8080
- LETSENCRYPT_HOST=mysubdomain1.domain.com,mysubdomain2.domain.com
- LETSENCRYPT_EMAIL=mymail@domain.com
但这似乎也不起作用,端口 8080 似乎根本不起作用。 我还尝试在 nginx-proxy 配置上指定端口8080
,但它不起作用:/
您是否将代理上的端口 8080 用于其他用途? 我只是在代理上使用 80 和 443 ......
如果您只在 eclipse-theia 上使用 8080,为什么不定义
ports:
- "8080:8080"
在 docker 上由 theia 而不是 nginx-proxy 组成?
代理具有意义,在端口 80 和 443 上使用多个域/子域,而不是使用奇怪的端口混乱。
我无法像您描述的那样解释如何使用它,因为我无法以这种方式使用它,因此我不会进一步深入研究。
所以我要做的就是将配置设置为:
version: '2.2'
services:
eclipse-theia:
restart: always
image: theiaide/theia:latest
init: true
environment:
- VIRTUAL_HOST=mysubdomain1.domain.com,mysubdomain2.domain.com
- LETSENCRYPT_HOST=mysubdomain1.domain.com,mysubdomain2.domain.com
- LETSENCRYPT_EMAIL=mymail@domain.com
并且在 jwilder/nginx-proxy 容器中安装了 apt 所以只需执行apt install nano
然后执行nano /etc/nginx/conf.d/default.conf
并将第二个上游端口从 3000 编辑到 8080 ,瞧,它可以工作了!
PS 不要将端口 8080 添加到 nginx-proxy 配置中,这完全没有必要!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.