如何使用Letsencrypt安全地在ssl上通过nginx-proxy在docker容器中运行Gitlab

前端之家收集整理的这篇文章主要介绍了如何使用Letsencrypt安全地在ssl上通过nginx-proxy在docker容器中运行Gitlab 前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我已经为此配置奋斗了好几天,无论我做什么,我都无法使其完全正常工作.谁能帮我吗??

我正在使用这里描述的解决方案:https://github.com/JrCs/docker-letsencrypt-nginx-proxy-companion,它对我所有其他容器都非常有效,但对gitlab而言却不是.使用这种方法,一旦登录了绿色的挂锁,只有gitlab登录页面是完全安全的,并且文本Secure消失并且https告诉我; “您与该站点的连接并不完全安全”.我已经检查了gitlab容器中的日志,它发现ssl证书很好,并且没有给出其他错误或表明有问题的提示.任何人?

文件:start.up

#!/bin/bash
docker run -d \
    --name ng \
    -p 80:80 \
    -p 443:443 \
    -v /etc/Nginx/conf.d  \
    -v /root/network/Nginx/vhost.d:/etc/Nginx/vhost.d \
    -v /root/network/Nginx/html:/usr/share/Nginx/html \
    -v /root/network/Nginx/certs:/etc/Nginx/certs:ro \
    -e DEFAULT_HOST=domain.com \
    -e VIRTUAL_PROTO=https \
    -e VIRTUAL_PORT=443 \
    --label com.github.jrcs.letsencrypt_Nginx_proxy_companion.Nginx_proxy \
    Nginx

docker run -d \
    --name ngg \
    --volumes-from ng \
    -v /root/network/Nginx/templates:/etc/docker-gen/templates:ro \
    -v /var/run/docker.sock:/tmp/docker.sock:ro \
    --label com.github.jrcs.letsencrypt_Nginx_proxy_companion.docker_gen \
    jwilder/docker-gen \
    -notify-sighup Nginx -watch -wait 5s:30s /etc/docker-gen/templates/Nginx.tmpl /etc/Nginx/conf.d/default.conf

docker run -d \
    --name ngl \
    --volumes-from ng \
    -v /var/run/docker.sock:/var/run/docker.sock:ro \
    -v /root/network/Nginx/certs:/etc/Nginx/certs:rw \
    jrcs/letsencrypt-Nginx-proxy-companion

文件:docker-compose.yml

version: "3"

services:

  gitlab:
    container_name: gl
    image: "gitlab/gitlab-ce:latest"
    restart: always
    hostname: "gitlab.domain.com"
    environment:
      GITLAB_OMNIBUS_CONFIG:
        external_url "https://gitlab.domain.com"
    expose:
    - 80
    - 443
    - 22
    volumes:
    - "./gitlab/config:/etc/gitlab"
    - "./gitlab/logs:/var/log/gitlab"
    - "./gitlab/data:/var/opt/gitlab"
    - "./Nginx/certs:/etc/gitlab/ssl"
    environment:
    - VIRTUAL_HOST=gitlab.domain.com
    - LETSENCRYPT_HOST=gitlab.domain.com
    - LETSENCRYPT_EMAIL=info@domain.com
    network_mode: "bridge"
最佳答案
我认为您在docker-compose.yml中缺少了Nginx配置.

environment:
  GITLAB_OMNIBUS_CONFIG: |
    external_url 'https://gitlab.example.com'
    Nginx['listen_port'] = 80
    Nginx['listen_https'] = false
    Nginx['proxy_set_headers'] = {
      "X-Forwarded-Proto" => "https","X-Forwarded-Ssl" => "on"
    }

以下要点对我有很大帮助!
https://gist.github.com/netdesk/c1db2985b542f9916995139318e5a7ce

原文链接:https://www.f2er.com/docker/532755.html

猜你在找的Docker相关文章