gpt4 book ai didi

docker - Nginx反向代理:使用jwilder/nginx-proxy为gitlab容器设置正确的端口

转载 作者:行者123 更新时间:2023-12-02 20:48:32 25 4
gpt4 key购买 nike

我需要使用Nginx反向代理。因此,我使用jwilder/nginx-proxy.
Also I'm using gitLab as a docker container.
So I came up with this docker-compose file, but accessing ci.server.com gives me a
502 Bad Gateway`错误。

我需要一些帮助来设置此Docker容器的正确端口

version: '3.3'
services:
nginx:
container_name: 'nginx'
image: jwilder/nginx-proxy:alpine
restart: 'always'
ports:
- 80:80
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro

gitlab:
container_name: gitlab
image: 'gitlab/gitlab-ce:10.0.2-ce.0'
restart: always
hostname: 'ci.server.com'
ports:
- '50022:22'
volumes:
- '/opt/gitlab/config:/etc/gitlab'
- '/opt/gitlab/logs:/var/log/gitlab'
- '/opt/gitlab/data:/var/opt/gitlab'
- '/opt/gitlab/secret:/secret/gitlab/backups'
- '/etc/letsencrypt:/etc/letsencrypt'
environment:
VIRTUAL_HOST: ci.server.com
VIRTUAL_PORT: 50022

在切换到Nginx反向代理之前,我使用了此docker-compose设置,该设置可以正常工作。我没有得到“转换”的不同或错误。


version: '3.3'
services:
nginx:
container_name: 'nginx'
image: 'nginx:1.13.5'
restart: 'always'
ports:
- '80:80'
- '443:443'
volumes:
- '/opt/nginx/conf.d:/etc/nginx/conf.d:ro'
- '/opt/nginx/conf/nginx.conf:/etc/nginx/nginx.conf:ro'
- '/etc/letsencrypt:/etc/letsencrypt'
links:
- 'gitlab'

gitlab:
container_name: gitlab
image: 'gitlab/gitlab-ce:10.0.2-ce.0'
restart: always
hostname: 'ci.server.com'
ports:
- '50022:22'
volumes:
- '/opt/gitlab/config:/etc/gitlab'
- '/opt/gitlab/logs:/var/log/gitlab'
- '/opt/gitlab/data:/var/opt/gitlab'
- '/opt/gitlab/secret:/secret/gitlab/backups'
- '/etc/letsencrypt:/etc/letsencrypt'

最佳答案

您应该在您的环境中设置VIRTUAL_PORT: 80

代理实际上正在尝试将80端口重定向到SSH端口。

要将SSL与jwilderproxy一起使用,您可以查看here

例如,我用这个。
version: '3/3'
services:
gitlab:
container_name: gitlab
image: 'gitlab/gitlab-ce:10.0.2-ce.0'
restart: always
hostname: 'ci.server.com'
ports:
- '50022:22'
volumes:
- '/opt/gitlab/config:/etc/gitlab'
- '/opt/gitlab/logs:/var/log/gitlab'
- '/opt/gitlab/data:/var/opt/gitlab'
- '/opt/gitlab/secret:/secret/gitlab/backups'
- '/etc/letsencrypt:/etc/letsencrypt'
environment:
- VIRTUAL_HOST=ci.server.com
- VIRTUAL_PORT=80
- LETSENCRYPT_HOST=ci.server.com
- LETSENCRYPT_EMAIL=youremail

关于docker - Nginx反向代理:使用jwilder/nginx-proxy为gitlab容器设置正确的端口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46808416/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com