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

相关推荐

  • 2016-10-18作业

    2016-10-17 课后作业  1. 生产环境发现一台服务器系统时间产生偏差,造成服务异常,请帮忙校正。     1)首先,查看本地硬件时间是否正确,命令如下:       hwclock       如果该时间是正确的,使用该时间来更新系统时间。命令如下: &nbs…

    Linux干货 2016-10-20
  • 系统基础之用户,组及权限管理

    用户及组详解 概论:   现今,大多数操作系统都是多用户(Multi-tasks)多任务(Mulit-Users)的系统.在多年前,计算机资源远没有现在这么丰富,都是多人使用同一台计算机,为了保障使用计算机的用户权益不受到损害,完成资源使用隔离,人们采取了用户机制标识使用者的方法.  每个使用者都是用户,用户是由UID进行标识,通过密码进…

    Linux干货 2016-08-04
  • Linux系统下的翻译神器——Goldendict

    Linux系统下的翻译神器——Goldendict 学习Linux时明显感受到学习英文的重要性。绝大多数Linux的发行版英文版的功能要远强于中文。因此一款好的翻译软件是了解熟悉Linux系统的必需品。在Windows系统下有各种好用的词典程序,包括有道词典、bing词典、金山词霸等等,而这些软件都不能在linux下使用,即使能够使用也只是测试版,功能太少。…

    Linux干货 2017-04-24
  • linux基础学习-第九天(shell基础)

    2016-08-10 授课内容: shell脚本基础: 变量 运算 bash测试(数字测试、字符测试、文件测试、组合测试) read命令 变量作用: 1、数据存储格式 2、参与的运算 3、表示的数据范围 变量类型: 1、本地变量 2、环境(全局)变量 3、特殊变量     驼峰命名变量:每个单词一个字母大写 本地变量:…

    Linux干货 2016-08-11
  • bash脚本编程实例

    bash脚本编程实例 1.写一个脚本 接受一个以上文件路径作为参数 显示每个文件拥有的行数 总结说明本次共为几个文件统计了其行数 #!/bin/bash # read -p “please input some paths:” paths if [ -z $paths ];then echo “There are not any paths inputtin…

    Linux干货 2017-08-14
  • MySQL高可用架构之Galera Cluster

    MySQL高可用架构之Galera Cluster 1、实验准备及拓扑 至少需要三个节点 node1 192.168.150.137 node2 192.168.150.138 node3 192.168.150.139 mariadb版本为mariadb的支持galera cluster的分支版本 MariaDB-Galera-server-5.5.46 …

    Linux干货 2017-03-31