nginx代理gitlab


編輯gitlab配置文件

  • 1、讓gitlab的內置nginx監聽7000端口

      nginx['listen_port'] = 7000
    
  • 2、 設置gitlab的訪問路徑(是通過外部nginx反向代理訪問的)

      external_url 'http://域名/gitlab'
    
  • 3、 讓配置生效

      $ gitlab-ctl reconfigure
      $ gitlab-ctl restart
    

配置外部nginx

  • 1、編輯nginx配置文件
$ vim /etc/nginx/nginx.conf

http {
    ...
    upstream git {
        server  localhost:7000;
    }
    server {
        listen 80;
        server_name 域名;
        location /gitlab {
            # 設置最大允許上傳單個的文件大小
            client_max_body_size 1024m;
            proxy_redirect off;
            #以下確保 gitlab中項目的 url 是域名而不是 http://git,不可缺少
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            # 反向代理到 gitlab 內置的 nginx
            proxy_pass http://git/gitlab;
            index index.html index.htm;
        }
    }
    ...
}
  • 2、重啟nginx

      # 檢測配置是否正確
      $ nginx -t
      
      # 重啟nginx
      $ nginx -s reload
      or service nginx restart


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM