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不生效?。。。。?/p>

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 17:22
下一篇 2015-09-06 20:00

相關推薦

  • mysql主從架構/模式

    MySQL Replication: Master/Slave Master: write/read Slaves: read 為什么? 冗余:promte(提升為主),異地災備 人工 工具程序 負載均衡:轉移一部分“讀”請求; 支援安全的備份操作: … 主/從架構: 異步復制:master只需要完成自己的數據庫操作即可。至于slaves是否收到…

    2016-11-27
  • Linux系統啟動流程與內管管理(上)

    在講linux系統啟動流程之前,來講講linux的組成,這樣能能幫助我們深入了解系統的啟動流程,廢話不多說直接上系統啟動流程圖 linux組成 linux:kernel+rootfs kenrel的作用:進程管理、內存管理、網絡管理、驅動程序、文件系統、安全管理等   rootfs:程序和glibc 庫:函數結合,function,調用接口(頭文件…

    系統運維 2016-09-14
  • 第四周小結

    這周我們主要學習了寫腳本的簡單語法,寫了一些簡單的腳本,下面就由我來簡單介紹一下: 第一步使用文本編輯來創建腳本: 創建好后在里面寫想要運行的腳本即可,然后按Esc—wq退出保存即可。也可以按q不保存退出;q!不保存強制退出;wq!保存強制退出。 第二步運行腳本,給予執行權限,在命令行上指定腳本的相對路徑和絕對路徑 對了,當在腳本里輸入內容時,要Ese&#8…

    2017-08-06
  • Memcached命令

    Memcache 的命令行用法: 1、啟動Memcache 常用參數    memcached 1.4.3      -p <num>      設置端口號(默認不設置為: 11211)      -U <num> &nbsp…

    Linux干貨 2015-05-18
  • Linux的發展史

    Linux的誕生 1987年荷蘭阿姆斯特丹Vrije大學的Andrew S.Tanenbaum 教授為了讓學生們更了解操作系統而參照Unix系統編寫了Minix系統。在1988年芬蘭赫爾辛基大學迎來了一位新生Linus Benedict Torvalds ,他在學習了Minix系統后,以此為平臺和指導開發出了Linux。在1991年8月Linus Toval…

    Linux干貨 2016-10-19
  • 相關練習

    1、請使用命令行展開功能來完成以下練習:    (1)、創建/tmp目錄下的:a_c, a_d, b_c, b_d  mkdir /tmp/{a,b}_{c,d}    (2)、創建/tmp/mylinux目錄下的:  mkdir -pv /tmp/mylinux/{bin,boot/grub,de…

    Linux干貨 2016-11-05
欧美性久久久久