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.www58058.com/7982

(2)
追馬追馬
上一篇 2015-09-06
下一篇 2015-09-06

相關推薦

  • mysql or條件可以使用索引而避免全表

    在某些情況下,or條件可以避免全表掃描的。 1 .where 語句里面如果帶有or條件, myisam表能用到索引, innodb不行。 1)myisam表:  CREATE TABLE IF NOT EXISTS `a` (   `id` int(1)&nb…

    Linux干貨 2015-04-13
  • 學習宣言

    我是喻成,我參加了馬幫第22期的linux運維網絡班,于2016年8月開始跟隨馬哥學習linux, 我的學習宣言是:要享受學習的每一刻,我思故我在。

    Linux干貨 2016-08-15
  • httpd服務——CentOS6

    Web Service 應用層:http,https 實現某類具體應用 傳輸層協議:TCP,UDP,SCTP IANA:          0-1023:從所周知的端口,永久的分配給固定應用使用,特權端口       &…

    Linux干貨 2016-10-09
  • 系統管理之磁盤管理(二)磁盤配額,RAID,LVM

    上篇博文給大家介紹了磁盤和文件系統的基礎知識,也是最基本的使用.在實際生產環境中,對于磁盤的使用,要求穩定,靈活,那么下面給大家分享下磁盤的高級用法.磁盤配額,RAID,LVM等相關知識. 1.磁盤配額2.磁盤RAID3.LVM 一.磁盤配額 1.概述: ? 在內核中執行 ? 以文件系統為單位啟用 ? 對不同組或者用戶的策略不同…

    Linux干貨 2016-09-05
  • vim文本操作、例行性工作、腳本編程_第六周練習(01)

    vim文本操作 Q1:復制/etc/rc.d/rc.sysinit文件至/tmp目錄,將/tmp/rc.sysinit文件中的以至少一個空白字符開頭的行的行首加#; [root@promote /]# cp /etc/rc.d/rc.sysinit /tmp/ [root@promote /]# l…

    Linux干貨 2016-12-18
  • N23-北京-阿來

           我是阿來,我參加了馬哥Linux運維網絡班,從2016年9月開始我將跟隨馬哥學習Linux技術。我的學習宣言是:學習的路,就在腳下,一步一個腳印,領路的人,就這這里,一天一點進步!

    Linux干貨 2016-09-12
欧美性久久久久