mrbear 发表于 2018-11-24 07:30:21

限速 apache centos mod_bw mod_limitipconn

  yum -y install httpd-devel
  ------------------------------- mod_bw------------------------------------
  1.先下载模块
  mod_bw-0.92.tgz
  mkdir -p bw && wget http://ivn.cl/files/source/mod_bw-0.92.tgz
  tar zxvf mod_bw-0.92.tgz
  /usr/local/apache2/bin/apxs -i -c -a ./mod_bw.c
  成功后,请检查httpd.conf里是否有
  LoadModule bw_module   modules/mod_bw.so
  默认会加上
  2.配置apache的主配置文件
  
  BandWidthModule On
  ForceBandWidthModule On
  BandWidth all 512000
  MinBandWidth all -1
  
  在最后加上,针对所有的IP限速0.5M。
  参考:http://legacy.ivn.cl/files/txt/mod_bw-0.92.txt
  ----------------------- mod_mod_limitipconn-----------------------
  wgethttp://dominia.org/djao/limit/mod_limitipconn-0.23.tar.bz2
  tar -jvxf mod_limitipconn-0.23.tar.bz2
  cd mod_limitipconn-0.23
  make install
  chmod -R 755 /usr/lib64/httpd/modules/mod_limitipconn.so
  vim /etc/httpd/conf/httpd.conf
  ExtendedStatus On
  MaxConnPerIP 2
  ------------------------------- more-------------------------------
  httpd -M
  LoadModulebw_module /usr/lib64/httpd/modules/mod_bw.so
  LoadModule limitipconn_module/usr/lib64/httpd/modules/mod_limitipconn.so
  Example:
  BandWidthModule On
  ForceBandWidthModule On
  BandWidth all 1024000
  MinBandWidth all -1
  MaxConnection all 1000
  LargeFileLimit * 5120 512000
  MaxConnPerIP 2
  
  
  ###mod-cband###
  wgethttp://cdnetworks-kr-1.dl.sourceforge.net/project/cband/mod-cband/mod-cband-0.9.6.1/mod-cband-0.9.6.1.tgz
  tar xvfz mod-cband-0.9.6.1.tgz
  cd mod-cband-0.9.6.1
  ./configure --with-apxs=/usr/sbin/apxs
  make && make install
  vim /etc/httpd/conf/httpd.conf
  
  # ServerAdminwebmaster@dummy-host.example.com
  # DocumentRoot /www/docs/dummy-host.example.com
  ServerNamelocalhost
  # ErrorLoglogs/dummy-host.example.com-error_log
  # CustomLoglogs/dummy-host.example.com-access_log common
  # 100MB virtualhost bandwidth limit
  CBandLimit 100M
  # Maximal 1024kbps speed for this virtualhost
  # Maximal 10 requests per second for this virtualhost
  # Maximal 30 open connections for this virtualhost
  CBandSpeed 1024 10 30
  # Maximal 10kB/s speed, 3 requests/s and 2 open connections for anyremote client
  CBandRemoteSpeed 10kb/s 3 2
  # a period of time after which the scoreboard will be cleared (4weeks)
  CBandPeriod 4W
  #Then you can access the status page with a URLlike:http://server_name/cband-status
  
  SetHandlercband-status
  
  #Then you can access the status page with a URLlike:http://server_name/cband-status-me
  
  SetHandlercband-status-me
  
  
  http://21.96.10.167/cband-status

页: [1]
查看完整版本: 限速 apache centos mod_bw mod_limitipconn