gitlab默认自带Nginx,可以通过修改/etc/gitlab/gitlab.rb配置文件来实现
1、查看gitlab配置文件/etc/gitlab/gitlab.rb
ll /etc/gitlab/
2.修改配置文件
vim /etc/gitlab/gitlab.rb
3.查找相关配置 custom_gitlab_server_config
# nginx['custom_gitlab_server_config'] = "location ^~ /foo-namespace/bar-project/raw/ {\n deny all;\n}\n"
追加以下内容到下方:
nginx['custom_gitlab_server_config'] = "location ~* (.*)
{
allow 10.0.1.1;
allow 10.0.1.0/24;
allow 10.0.1.0/16;
deny all;
proxy_cache off;
proxy_pass http://gitlab-workhorse;
root html;
index index.html index.htm;
}"
相关配置可以查看gitlab官方文档地址
注意:deny和allow的顺序不要弄反了,nginx的location会从上往下匹配,如果deny all;放在最上边的话,下方的allow都不起作用了。
4.配置gitlab
gitlab-ctl reconfigure
5、重启
gitlab-ctl restart
网友评论