0

我需要使用 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 a502 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'
4

1 回答 1

3

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

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

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

例如,我用这个。

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

于 2017-10-18T11:38:39.210 回答