限制IP访问服务器有很多的方法! 可以设置防火墙或其他的方法

下面是设置httpd 的配置文件来限制IP的访问

  1. <Directory "/var/www/html"> 
  2. # Possible values for the Options directive are "None", "All", 
  3. # or any combination of: 
  4. #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews 
  5. # Note that "MultiViews" must be named *explicitly* --- "Options All" 
  6. # doesn't give it to you. 
  7. # The Options directive is both complicated and important.  Please see 
  8. # http://httpd.apache.org/docs-2.0/mod/core.html#options 
  9. # for more information. 
  10.     Options 
  11. # AllowOverride controls what directives may be placed in .htaccess files. 
  12. # It can be "All", "None", or any combination of the keywords: 
  13. #   Options FileInfo AuthConfig Limit 
  14.     AllowOverride None 
  15. # Agregado para redirigir el http a https 
  16.  
  17. #    RewriteEngine On 
  18. #    RewriteCond %{HTTPS} off 
  19. #    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} 
  20.  
  21. # Controls who can get stuff from this server. 
  22. # 设置可以访问服务器的IP
  23.     Allow From 192.168.1.12 220.133.*.*/255.255.255.255 
  24.     Order deny,allow 
  25.     Deny from all 
  26. </Directory>