@Allanian

Как донастроить Gitlab-omnibus с внешним nginx и https?

  1. создал собственные сертификаты
  2. /etc/hosts - 172.39.64.68 gitlab.mydomain.com

Переход по ссылке возвращает 502 ошибку.
https://gitlab.mydomain.com
В логах появляется запись:
with error: *1 connect() to unix:/var/opt/gitlab/gitlab-workhorse/socket failed (2: No such file or directory) while connecting to upstream, client: 172.17.0.1, server: gitlab.mydomain.com, request: "GET / HTTP/2.0", upstream: "http://unix:/var/opt/gitlab/gitlab-workhorse/socket:/", host: "gitlab.mydomain.com"

docker-compose.yml
gitlab:
  image: 'gitlab/gitlab-ce:latest'
  restart: always
  hostname: 'gitlab.mydomain.com'
  container_name: gitlab
  environment:
    GITLAB_OMNIBUS_CONFIG: |
      external_url 'http://gitlab.mydomain.com'
      nginx['enable'] = true
      nginx['listen_port'] = 50443
      nginx['listen_addresses'] = ['0.0.0.0', '[::]']
      nginx['listen_https'] = false
      nginx['redirect_http_to_https'] = true
      gitlab_rails['trusted_proxies'] = ['172.17.0.0/16','192.168.1.0/24','172.29.74.0/24','172.29.74.12','172.19.0.2']
      nginx['ssl_certificate'] = "/etc/gitlab/ssl/gitlab.crt"
      nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/gitlab.key"
      letsencrypt['enable'] = false
      nginx['proxy_set_headers'] = {
        "X-Forwarded-Proto" => "https",
        "X-Forwarded-Ssl" => "on"      
      }
      gitlab_rails['time_zone'] = 'Asia/Yekaterinburg'
      gitlab_rails['gitlab_shell_ssh_port'] = 2022 
      web_server['external_users'] = ['nginx','gitlab-www','git']
  ports:
    - '50443:443'
    - '2022:22'
  volumes:
    - ./gitlab/config:/etc/gitlab
    - ./gitlab/logs:/var/log/gitlab
    - ./gitlab/data:/var/opt/gitlab
    - ./nginx/ssl:/etc/gitlab/ssl

nginx:
  container_name: nginx
  image: nginx:latest
  restart: always
  container_name: nginx
  links:                           
    - gitlab:gitlab
  ports:
    - 80:80
    - 443:443
  volumes:
    - ./nginx/ssl:/etc/nginx/ssl
    - ./nginx/logs:/var/log/nginx
    - ./nginx/conf.d:/etc/nginx/conf.d
    - ./nginx/nginx.conf:/etc/nginx/nginx.conf


config for nginx: gitlab.mydomain.com.conf
spoiler
upstream gitlab-workhorse {
server unix:/var/opt/gitlab/gitlab-workhorse/socket fail_timeout=0;
}

server {
listen 80;
server_name gitlab.mydomain.com;
return 301 https://$server_name$request_uri:9090;
}

server {
listen *:80;
server_tokens off;
return 301 https://$http_host$request_uri;
access_log /var/log/nginx/gitlab_access.log;
error_log /var/log/nginx/gitlab_error.log;
}

#HTTPS
server {
listen 0.0.0.0:443 ssl http2;
listen [::]:443;
server_name gitlab.mydomain.com;
server_tokens off;
root /opt/gitlab/embedded/service/gitlab-rails/public;
client_max_body_size 100m;
ssl_certificate /etc/nginx/ssl/gitlab.crt;
ssl_certificate_key /etc/nginx/ssl/gitlab.key;

ssl_ciphers "ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4";
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 1h;
ssl_dhparam /etc/nginx/ssl/dhparam.pem;
real_ip_header X-Real-IP;
real_ip_recursive off;

access_log /var/log/nginx/gitlab_access.log;
error_log /var/log/nginx/gitlab_error.log error;

location / {

gzip off;

proxy_read_timeout 600;
proxy_send_timeout 600;
proxy_connect_timeout 600;
send_timeout 600;
proxy_redirect off;

proxy_http_version 1.1;

proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Ssl on;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header X-CSRF-Token $http_x_csrf_token;
proxy_redirect off;
proxy_set_header X-Frame-Options SAMEORIGIN;

proxy_pass http://gitlab-workhorse;
}
}
  • Вопрос задан
  • 5008 просмотров
Решения вопроса 1
Tyranron
@Tyranron
Вы на Nginx'е, получается, TLS-терминацию делаете, а GitLab при этом у Вас тоже пытается слушать по HTTPS. Вам нужно сказать GitLab'у, чтобы слушал обычный HTTP, и что он позади reverse proxy. И обращаться к нему не по unix-сокету Workhorse (именно на это у Вас ругается Nginx), а напрямую на нужный порт.

Что-то вроде этого:
external_url 'https://gitlab.mydomain.com'
nginx['listen_port'] = 80
nginx['listen_https'] = false
nginx['proxy_set_headers'] = {
  "Host" => "$http_host_with_default",
  "X-Real-IP" => "$remote_addr",
  "X-Forwarded-For" => "$proxy_add_x_forwarded_for",
  "X-Forwarded-Proto" => "https",
  "X-Forwarded-Ssl" => "on",
  "Upgrade" => "$http_upgrade",
  "Connection" => "$connection_upgrade"
}

ports:
    - '8080:80'
    - '2022:22'

proxy_pass http://gitlab:8080;

Но конкретно в данной ситуации не совсем понятно, зачем Вам нужен ещё один фронтовый Nginx рядом. Вы ведь можете просто потюнить на предмет сертификатов/шифров тот Nginx, который уже идёт внутри omnibus образа.
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы