2017-10-18 150 views
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 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配置是什麼? –

回答

2

您應該設置在您的環境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