如何将linux VM上的流量限制到某个IP范围?

时间:2017-10-27 13:46:51

标签: linux apache ubuntu ubuntu-16.04

我是Linux的新手,已经为Rails应用程序启动并运行了VM。我想限制网站的流量,以便只有我组织内的人才能访问该网站。如果我有这个范围,我如何在Ubuntu中限制流量?

我正在使用Apache的Ubuntu 16.04 LTS。

编辑:以下是该网站的配置文件:

<VirtualHost *:80>
PassengerRuby /home/user/.rbenv/shims/ruby
ServerName site.com
ServerAlias alias.com
ServerAdmin username
DocumentRoot /home/username/rails/site/public/
RailsEnv development
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory "/home/username/rails/site/public/">
    Options FollowSymLinks
    Require all granted
    Options -MultiViews
</Directory>

<LocationMatch "server.com">
  order deny,allow
  deny from all
  allow from xxx.xxx.0.0/16
</LocationMatch>

</VirtualHost>

1 个答案:

答案 0 :(得分:0)

看看Apache LocationMatch指令。将指令置于虚拟主机规范中。例如:

<LocationMatch "/your/specific/url"> order deny,allow deny from all allow from xxx.xxx.xxx.xxx/xx </LocationMatch>