Gitlab:反向代理的HTTPs

时间:2019-11-03 17:23:11

标签: nginx gitlab reverse-proxy

当前,我正在尝试在Nginx反向代理后面使用我的Gitlab,因为我在同一台计算机上使用了其他一些工具。因此,它应该以以下方式工作:客户端<-> reverse_proxy <-> Gitlab。 我想要的是将Gitlab配置为在本地主机上侦听HTTP的端口9080和HTTPS的9081(以接收来自我的反向代理的重定向数据)。但是我在配置此文件时遇到了一些问题。

  1. 捆绑的nginx服务器始终对HTTP使用端口9081,对于HTTPS使用9080。但是,无论我尝试使用哪种配置,结果都是相同的。除非将external_url与https和端口9081一起使用,否则捆绑的nginx将对HTTP和HTTPS使用端口9081。
  2. 对于HTTPS重定向,捆绑的nginx始终使用Gitlab.rb中配置的属性“ external_url”中的端口,但应使用属性“ redirect_http_to_https_port”中配置的端口。

对我来说,生成的配置文件没有任何意义,但也许我误解了文档。 所以这是我在Gitlab.rb中所做的更改,以及从/ var / opt / gitlab / nginx / conf /

中生成的gitlab-http.conf

Gitlab.rb中的相关更改:

  • external_url'http://localhost:9080/subdir'
  • web_server ['external_users'] = ['nginx]
  • nginx ['enable'] = true
  • nginx ['redirect_http_to_https'] = true
  • nginx ['redirect_http_to_https_port'] = 9081
  • nginx ['ssl_certificate'] =“ path_to_cert_file”
  • nginx ['ssl_certificate_key'] =“路径_密钥_文件”
  • nginx ['listen_port'] = 9080
  • nginx ['listen_https'] = 9081
  • nginx [http2_enables'] = false
  • letsencrypt ['enable'] = false

gitlab-http.conf的相关部分:

server {
  listen *:9081;

  server_name localhost;
  server_tokens off; ## Don't show the nginx version number, a security best practice


  location / {
    return 301 https://localhost:9080$request_uri;
  }

...
}

server {
  listen *:9080 ssl;


  server_name localhost;
  server_tokens off; ## Don't show the nginx version number, a security best practice

  ## Increase this if you want to upload large attachments
  ## Or if you want to accept large git objects over http
  client_max_body_size 0;

  ## Strong SSL Security
  ## https://raymii.org/s/tutorials/Strong_SSL_Security_On_nginx.html & https://cipherli.st/
  ssl_certificate "path_to_cert_file";
  ssl_certificate_key "path_to_key_file";

...
}

0 个答案:

没有答案
相关问题