进行Web访问认证
默认情况下,编译Apache时自动加入mod_auth模块,利用此模块可以实现“用户名+密码”以文本文件为存储方式的认证功能。
(1)修改Apache的配置文件/usr/local/apache/conf/httpd.conf,对认证资源所在的目录设定配置命令。下面是对/usr/local/apache/htdocs/ntop目录的配置:
<Directory /usr/local/apache/htdocs/ntop>
Options Indexes FollowSymLinks
allowoverride authconfig #表示允许对/usr/local/apache/htdocs/ntop目录下的文件进行用户认证#
order allow,deny
allow from all
</Directory>
(2)在限制访问的目录/usr/local/apache/htdocs/ntop下建立一个文件.htaccess,其内容如下:
AuthName ""
AuthType basic
AuthUserFile/usr/local/apache/ntop.txt
require ntop #ntop用户可以访问#

(3)利用Apache附带的程序htpasswd,生成包含用户名和密码的文本文件/usr/local/apache/ntop.txt,每行内容格式为“用户名:密码”。
#cd /usr/local/apache/bin
#htpasswd -bc ../ntop.txt user1 234xyx14
欲了解htpasswd程序的帮助,请执行“htpasswd –h”。
(4)重新启动Apache服务器。然后在浏览器中输入localhost访问新建好的站点。这时就会要求输入用户名和口令,如图17-13所示。
加密连接NTOP
NTOP支持SSL加密连接,为了防止非授权用户查看NTOP提供的网络信息,你可以使用SSL加密连接NTOP服务器与浏览器的数据。首先修改配置文件/etc/ntop.conf,使用以下选项:
--user ntop
### Sets the directory that ntop runs from.
--db-file-path /var/ntop
### Interface(s) that ntop will capture on (default: eth0)
#--interface eth0
### Configures ntop not to trust MAC addrs. This is used when port mirroring or SPAN
#--no-mac
### Logging messages to syslog (instead of the console):
### NOTE: To log to a specific facility, use --use-syslog=local3
### NOTE: The = is REQUIRED and no spaces are permitted.
--use-syslog
### Tells ntop to track only local hosts as specified by the --local-subnets option
#--track-local-hosts
### Sets the port that the HTTP webserver listens on
### NOTE: --http-server 3000 is the default
#--http-server 3000
###表示使用https连接#
--https-server 3001
### Sets the networks that ntop should consider as local.
### NOTE: Uses dotted decimal and CIDR notation. Example: 192.168.0.0/24
### The addresses of the interfaces are always local and don't need to be
specified.
#--local-subnets xx.xx.xx.xx/yy
### Sets the domain. ntop should be able to determine this automatically.
#--domain mydomain.com
### Sets program to run as a daemon
### NOTE: For more than casual use, you probably want this.
#--daemon
然后使用命令启动HTTPS连接和NTOP服务器。
apachectl stop
apachectl startssl
ntop start
注意 此时使用的是3001端口。
加密连接界面如图17-14所示。

图 加密连接界面
SSL加密技术可以使NTOP提供的信息更加安全。只有授权用户可以查看。
