gitlab-ce并发超过30引起ip被封1小时的问题

系统环境描述

System information
System:     Ubuntu 14.04
Current User:   git
Using RVM:  no
Ruby Version:   2.1.5p273
Gem Version:    2.2.1
Bundler Version:1.5.3
Rake Version:   10.3.2
Sidekiq Version:3.3.0

GitLab information
Version:    7.8.1
Revision:   e2d785c
Directory:  /opt/gitlab/embedded/service/gitlab-rails
DB Adapter: postgresql
URL:        https://git.zhuima.com
HTTP Clone URL: https://git.zhuima.com/some-project.git
SSH Clone URL:  ssh://git@git.zhuima.com:10086/zhuima.git
Using LDAP: yes
Using Omniauth: no

GitLab Shell
Version:    2.5.4
Repositories:   /data/gitlab/data/repositories
Hooks:      /opt/gitlab/embedded/service/gitlab-shell/hooks/
Git:        /opt/gitlab/embedded/bin/git

问题症状

每天总有一段时间会出现403的情况
办公网不能访问位

拍错思路

1、日志中出现401、403状态吗

2、gitlab-rake gitlab:check发现的问题 [修复未能解决问题]

    zhuima-library / yii-framework ... no
      Try fixing it:
      sudo -u git -H bundle exec rake gitlab:satellites:create RAILS_ENV=production
      If necessary, remove the tmp/repo_satellites directory ...
      ... and rerun the above command
      For more information see:
      doc/raketasks/maintenance.md

3、网上的文档搜索相关文档

http://boardreader.com/thread/Gitlab_7_10_4_Forbidden_Error_56o55lX769.html
怀疑是rack_attack.rb文件的策略导致的,修改文件,重启不生效

rack_attack.rb文件的额配置,修改1s并发300不生效!!!!!

unless Rails.env.test?
  Rack::Attack.throttle('protected paths', limit: 300, period: 1.seconds) do |req|
    if req.post? && req.path =~ paths_regex
      req.ip
    end
  end
end

其他

每次服务中断时间为1小时

该时间段内没有设置任务计划
gitlab是通过ladp进行账号验证的

仅仅办公网不能正常访问gitlab,外部网络访问正常

1、仅仅办公网不能正常访问gitlab,外部网络访问正常
2、办公网络开发人数150+
3、并发30+

需要解决的问题

想要的效果

1、如何禁用rack_attack.rb的策略
2、稳定的服务

相关日志

Started GET "/" for 127.0.0.1 at 2015-09-02 16:57:50 +0800
Processing by DashboardController#show as */*
Completed 401 Unauthorized in 44ms

=========
==> /var/log/gitlab/nginx/gitlab_access.log <==
118.187.12.36 - - [02/Sep/2015:16:47:33 +0800] "GET /zhuima-egg/zhuima.git/info/refs?service=git-upload-pack HTTP/1.1" 403 20 "-" "git/1.9.5.msysgit.1"

排错过程中所做的操作

1_settings.rb中定义的

1_settings.rb中添加白名单,生效,但是gitlab-ctl reconfigure之后配置被初始化

Settings['rack_attack'] ||= Settingslogic.new({})
Settings.rack_attack['git_basic_auth'] ||= Settingslogic.new({})
Settings.rack_attack.git_basic_auth['enabled'] = true if Settings.rack_attack.git_basic_auth['enabled'].nil?
Settings.rack_attack.git_basic_auth['ip_whitelist'] ||= %w{127.0.0.1}
Settings.rack_attack.git_basic_auth['ip_whitelist'] ||= %w{118.187.12.36}
Settings.rack_attack.git_basic_auth['maxretry'] ||= 10
Settings.rack_attck.git_basic_auth['findtime'] ||= 1.minute
Settings.rack_attack.git_basic_auth['bantime'] ||= 1.hour

禁用rack_attack.rb文件

http://boardreader.com/thread/Gitlab_7_10_4_Forbidden_Error_56o55lX769.html

关于rack_attack

rack-attack: 基于 Rack 的防攻击中间件
https://github.com/kickstarter/rack-attack
https://github.com/kickstarter/rack-attack/wiki/Example-Configuration

官方文档的解释:

http://doc.gitlab.com/ce/security/rack_attack.html

http://boardreader.com/thread/Gitlab_7_10_4_Forbidden_Error_56o55lX769.html

rack_attack配置在案例·

https://gitlab.com/gitlab-org/omnibus-gitlab/issues/480

gitlab-ce 9.10归档整理

https://about.gitlab.com/downloads/archives/

gitlab 7.9版本之后的rack_attack.rb配置示例:

https://github.com/kickstarter/rack-attack/wiki/Example-Configuration

参考文档

https://code.csdn.net/zhanglushan/gitlabhq/tree/0b1cf50060de0d0a3039dfb2fca47364c7fb5f82/doc/raketasks/maintenance.md

原创文章,作者:追马,如若转载,请注明出处:http://www.178linux.com/7982

(2)
追马追马
上一篇 2015-09-06 17:22
下一篇 2015-09-06 20:00

相关推荐

  • 源码安装http

    http://xxlii.blog.51cto.com/10277731/1841570     哈哈!

    Linux干货 2016-08-24
  • N25-第二周作业

    第二周作业 1.Linux上的文件管理命令都有哪些,其常用的使用方法及相关示例演示。 Linux上的文件管理命令有:cp , mv , rm 等命令 cp是复制命令: 命令使用格式是: cp [OPTION]… SOURCE… DEST 例:root@vps ~]# cp /etc/passwd /tmp 复制…

    Linux干货 2016-12-14
  • Linux下的文件管理系统

    一、文件系统的FHS标准     因为Linux的属于开源系统,开发人员多,为了统一开发标准,Linux有一个文件系统标准,也就是FHS(Filesystem HierarchyStandard)标准。有了这个标准,那些独立的软件开发商、系统开发人员以及系统的使用者就能方便的在系统上操作。 二、文件系统  &…

    Linux干货 2016-08-02
  • python基础_1

    变量/常量 常量:一旦赋值,就不能对它从新复制。python不存在常量 字面常量:一个单独出现的量,未赋值给任何变量或者常量 变量:就是一个名字,在固执符号的左边,这个名字可以指复制符号右边的内容。 变量列子: i = 3 print(i)  注:python 是强类型语言,是动态类型语言。(强类型指类型之间不能相互计算/动态类型是指变量是可以赋值…

    Linux干货 2017-10-10
  • 文件权限管理

    一 、文件属性介绍 1、linux文件权限分为读(read)、写(write)、执行(excute)三种,主要针对三类用户进行定义:ouwer:属主(u) 、group(g):属组、 other(o):其他人。文件的权限组合可以分为两种,一种是由三个字母r 、w、 x组成,一种是由数字组成4、2、1,它们代表的意思是r = 4 表示读权限、w = 2表示写权…

    Linux干货 2016-08-08
  • Javascript 装载和执行

    一两个月前在淘宝内网里看到一个优化Javascript代码的竞赛,发现有不少的人对Javascript的执行和装载的基础并不懂,所以,从那天起我就想写一篇文章,但一直耽搁了。自上篇《浏览器渲染原理简介》,正好也可以承前启后。 首先,我想说一下Javascript的装载和执行。通常来说,浏览器对于Javascript的运行有两大特性:1)载入后马上执行,2)执…

    Linux干货 2016-08-15