使用Docker Compose将Omnisus Gitlab的HTTP HTTP重定向为自定义HTTPS端口

时间:2018-06-28 14:05:32

标签: docker-compose dockerfile gitlab-ci http-redirect gitlab-omnibus

我拥有最新的Omnibus GitLab Docker映像,docker-compose.yml如下所示:

web:
  image: 'gitlab/gitlab-ce:latest'
  restart: always
  hostname: 'some_ip'
  container_name: 'some_name'
  environment:
    GITLAB_OMNIBUS_CONFIG: |
      external_url 'https://some_ip'
      gitlab_rails['gitlab_shell_ssh_port'] = 4381
      nginx['redirect_http_to_https'] = true
      nginx['redirect_http_to_https_port'] = 80
  ports:
    - '6312:443'
    - '4381:22'
  volumes:
    - '/srv/gitlab/config:/etc/gitlab'
    - '/srv/gitlab/logs:/var/log/gitlab'
    - '/srv/gitlab/data:/var/opt/gitlab'

访问https://some_ip:6312时可以正常工作,但对于some_ip:6312则显示:

  

400错误的请求普通的HTTP请求已发送到HTTPS端口nginx

原因很明显,但是如何解决呢?我必须为nginx设置ssl off,如果是的话,如何为Docker映像设置呢?

我尝试过添加以下几行的不同组合,但没有成功:

nginx['redirect_http_to_https'] = true
nginx['redirect_http_to_https_port'] = 80
gitlab_rails['gitlab_https'] = false
gitlab_rails['gitlab_port'] = 443
nginx['ssl'] = 'off'
nginx['listen_port'] = 443
nginx['listen_https'] = false

编辑: 简而言之:我希望将通过some_ip:6312http://some_ip:6312连接到网站的用户重定向https://some_ip:6312

1 个答案:

答案 0 :(得分:0)

不可能在同一端口上运行httphttps

https://askubuntu.com/questions/860511/is-it-possible-to-set-same-port-work-with-http-and-https

当您使用https://domain/时,端口将自动假定为443,对于http://domain/,端口将被假定为80。因此,它们实际上都在不同的端口上运行。