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://[email protected]: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

相关推荐

  • 简单明了的Linux常用端口说明

    由于Linux常用端口很多,为了查看方便,所以特意整理了一些,详情如下        查看Linux常用端口   cat /etc/services # The Well Known Ports are those from 0 through 1023. 众所周知的端口是从0到1023。 # The Reg…

    Linux干货 2017-06-11
  • 用户和组相关配置文件

    1. /etc/passwd文件详解 输入vi /etc/passwd 可以查看此文件的内容 [root@localhost ~]# vi /etc/passwdroot:x:0:0:root:/root:/bin/bash root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/…

    Linux干货 2016-10-23
  • linux系统上命令使用格式及常见命令

    [root@localhost ~]# date -d ‘2017-07-06 00:00:00 ‘  用上面这条指令讲解命令使用格式 date command  -d 是参数,参数有可选参数,必选参数,在参数前必选加上- ,还是以这条指令为列,-d可以写成–date,如果写成date,date前面必选…

    Linux干货 2017-08-19
  • RPM及YUM工具介绍及使用(上)

    写在前面 常见的计算机硬件平台大致可以为分:x86、x86_64、amd64、ppc、arm、aarch64。软件平台,在Linux界则是指不同的Linux发行版。 Linux系统中的软件(非源码)由于都是在不同的硬件+软件平台开发编译完成之后发布的,因此同一个软件会区分硬件和软件环境而有不同的软件包。在安装软件时应该选择与自己的硬件和软件平台一致的软件包进…

    Linux干货 2016-12-26
  • 上篇博客简单提了一下Nginx配置文件的大体组成部分,这次来好好解释一下这些个配置文件。 一、main配置段 分类:    正常运行必备的配置    优化性能相关的配置    用于调试及定位问题相关的配置   …

    Linux干货 2016-10-26
  • N26-博客作业-week11

    1、详细描述一次加密通讯的过程,结合图示最佳。 加密过程 1、先用单向加密算法计算出数据的特征码 2、私钥加密特征码,并将结果附加在数据之后 3、生成一个临时的对称密钥,并使用对称密钥加密整段数据 4、获取对方的公钥,使用该公钥加密之前生成的临时对称密钥,并附加在数据之后 5、将所有数据发送给对方解密过程 1、先使用私钥解密加密的对称密钥 2、用对称密钥解密…

    2017-04-18