通过nginx代理的Docker环境导致502 Bad Gateway

时间:2017-08-14 11:49:05

标签: docker nginx docker-compose gitlab jwilder-nginx-proxy

我正在使用nginx-proxy将子域连接到不同的docker服务。由于最后一次图像更新,我无法再连接到我的gitlab实例。我不知道nginx-proxy或gitlab更新是否导致了这个问题。当我尝试连接到gitlab.mydomain.com时,我收到以下错误:

  1. 浏览器:502 Bad Gateway。 nginx的/ 1.13.3
  2. nginx-proxy logs:

    nginx-proxy_1 | nginx.1 | 2017/08/14 11:44:10 [错误] 39#39:* 1672 connect()失败(111:连接被拒绝)连接上游,客户端:178.201.120.94,服务器:gitlab.mydomain.com,请求: " GET / HTTP / 2.0",上游:" https://172.18.0.2:443/",主持人:" gitlab.mydomain.com"

    nginx-proxy_1 | nginx.1 | gitlab.mydomain.com 178.201.120.94 - - [14 / Aug / 2017:11:44:10 +0000]" GET / HTTP / 2.0" 502 575" - " " Mozilla / 5.0(Windows NT 10.0; Win64; x64)AppleWebKit / 537.36(KHTML,与Gecko一样)Chrome / 60.0.3112.90 Safari / 537.36"

    nginx-proxy_1 | nginx.1 | 2017/08/14 11:44:11 [错误] 39#39:* 1672 connect()失败(111:连接被拒绝)连接上游,客户端:178.201.120.94,服务器:gitlab.mydomain.com,请求: " GET /favicon.ico HTTP / 2.0",上游:" https://172.18.0.2:443/favicon.ico",主持人:" gitlab.mydomain.com",推荐人: " https://gitlab *** COM /"

  3. 我的docker-compose文件:

    version: '2'
    
    services:
       nginx-proxy:
         image: jwilder/nginx-proxy
         ports:
         - "80:80"
         - "443:443"
         volumes:
         - /var/local/nginx/certs:/etc/nginx/certs
         - /etc/letsencrypt:/etc/letsencrypt
         - /var/run/docker.sock:/tmp/docker.sock:ro
    
       gitlab:
         image: gitlab/gitlab-ce:latest
         ports:
         - "2222:22"
         hostname: 'gitlab.***.com'
         expose:
         - 443
         - 22
         - 80
         - 25
         environment:
         - "VIRTUAL_HOST=gitlab.***.com,www.gitlab.***.com"
         - "VIRTUAL_PORT=443"
         - "VIRTUAL_PROTO=https"
         volumes:
         - "gitlab-config:/etc/gitlab"
         - "gitlab-log:/var/log/gitlab"
         - "gitlab-data:/var/opt/gitlab"
         - "/etc/letsencrypt:/etc/letsencrypt"
    

    有什么想法吗?谢谢。
    修改 来自docker的网络设置检查gitlab:

        "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "...",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {
                "22/tcp": [
                    {
                        "HostIp": "0.0.0.0",
                        "HostPort": "2222"
                    }
                ],
                "25/tcp": null,
                "443/tcp": null,
                "80/tcp": null
            },
            "SandboxKey": "/var/run/docker/netns/...",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "",
            "Gateway": "",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "IPAddress": "",
            "IPPrefixLen": 0,
            "IPv6Gateway": "",
            "MacAddress": "",
            "Networks": {
                "docker_default": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": [
                        "abb170528bcc",
                        "gitlab"
                    ],
                    "NetworkID": "...",
                    "EndpointID": "...",
                    "Gateway": "172.18.0.1",
                    "IPAddress": "172.18.0.2",
                    "IPPrefixLen": 16,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "02:42:ac:12:00:02"
                }
            }
        }
    

1 个答案:

答案 0 :(得分:0)

这个设置对我有用,也许你可以比较它,找出错误:

https://superuser.com/a/1242682/762931

也许是这样的: https://gitlab.com/gitlab-org/omnibus-gitlab/issues/1307