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

问题描述:

我需要使用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错误网关错误。Nginx反向代理:使用jwilder/nginx-proxy为gitlab容器设置正确的端口

我需要一些帮助建立正确的端口为这个搬运工容器

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的我用这个搬运工,撰写的设置,这是工作的反向代理。我没有得到我通过'转换'这个差异或错误。

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' 
+0

你之前的nginx配置是什么? –

您应该设置在您的环境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

+0

你能解释一下我的gitlab配置吗?我疯狂的与端口...我通过SSL调用gitlab,所以我试图公开443和virtual_port也443 – user3142695