A
A
Alexander Fadeev2018-07-17 17:10:15
Nginx
Alexander Fadeev, 2018-07-17 17:10:15

How to link gitlab and nginx containers?

there is docker-compose.yml:

version: '3'
services:
    php:
        container_name: "php"
        build: ./php/
        expose:
            - "9000"
        ports:
            - "9000:9000"
        links:
            - mysql
            - memcached
            - adminer
        volumes:
            - ./www:/var/www
            - ./php:/usr/local/etc/php
        restart: always
    nginx:
        restart: always
        image: nginx:latest
        ports:
            - "80:80"
            - "443:443"
        volumes:
            - ./hosts:/etc/nginx/conf.d
            - ./www:/var/www
            - ./logs:/var/log/nginx
        depends_on:
            - php
            - gitlab
        links:
            - php
            - gitlab:gitlab
    mysql:
        restart: always
        image: mysql
        ports:
            - "3306:3306"
        volumes:
            - ./mysql:/var/lib/mysql
        environment:
            MYSQL_ROOT_PASSWORD: root
    adminer:
        image: adminer
        restart: always
        ports:
            - 8080:8080
        links:
            - mysql
    memcached:
        image: memcached 
        expose:
            - "11211"
        ports:
          - "11211:11211"
        restart: always
    gitlab:
        restart: always
        container_name: "gitlab"
        image: 'gitlab/gitlab-ce:latest'
        restart: always
        hostname: 'gitlab.loc'
        environment:
            GITLAB_OMNIBUS_CONFIG: |
              gitlab_rails['gitlab_shell_ssh_port']=22;
        ports:
            - '0.0.0.0:32781:80'
            - '4430:443'
            - '22:22'  
        volumes:
            - './gitlab/config:/etc/gitlab'
            - './gitlab/logs:/var/log/gitlab'
            - './gitlab/data:/var/opt/gitlab'
        expose:
            - "8091"

there is also an nginx config:
server {
    listen 80;
    server_name gitlab.loc;
    error_log  /var/log/nginx/nginx_error.log;
    access_log /var/log/nginx/nginx_access.log;

    location / {
        proxy_set_header   X-Real-IP $remote_addr;
        proxy_set_header   Host      $http_host;
        proxy_pass         http://localhost:32781;  
    }
}

I tried to write instead of localhost the ip of the container with gitlab and the name of the container and the local host - it always gives a 502 error. At the same time, the container replies
at gitlab.loc:32781 .
Tell me how to make nginx proxy requests to gitlab?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
H
Hikmat Abdunabiev, 2018-07-17
@Khikmat

Try specifying like this:
proxy_pass http://gitlab:32781;

M
m_kostelcev, 2018-07-17
@m_kostelcev

proxy_pass http://gitlab.loc:32781
At the same time, from the machine on which the nginx server is running - everything should open at the address above.

E
EgorLyutov, 2018-07-18
@EgorLyutov

proxy_pass http://gitlab:80;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question