参考资料
[1]. 跟老男孩学Linux运维:Web集群实战,老男孩
安装过程
编辑配置文件
[root@www ~]# vi /application/nginx/conf/extra/www.conf
server{
listen 80;
server_name www.etiantian.org etiantian.org;
root html/www;
access_log logs/access_www.log main gzip buffer=32k flush=5s;
location / {
return 401;
}
location = / {
return 402;
}
location /documents/ {
return 403;
}
location ^~ /images/ {
return 404;
}
location ~* \.(gif|jpg|jpeg)$ {
return 500;
}
}
检查并重新加载
[root@www ~]# /application/nginx/sbin/nginx -t
[root@www ~]# /application/nginx/sbin/nginx -s reload
测试
[root@www ~]# curl -s -o /dev/null -I -w "%{http_code}\n" http://www.etiantian.org
[root@www ~]# curl -s -o /dev/null -I -w "%{http_code}\n" http://www.etiantian.org/index.html
[root@www ~]# curl -s -o /dev/null -I -w "%{http_code}\n" http://www.etiantian.org/documents/documents.html
[root@www ~]# curl -s -o /dev/null -I -w "%{http_code}\n" http://www.etiantian.org/images/1.gif
[root@www ~]# curl -s -o /dev/null -I -w "%{http_code}\n" http://www.etiantian.org/documents/1.jpg
[root@www ~]# curl -s -o /dev/null -I -w "%{http_code}\n" http://www.etiantian.org/oldboy/
[root@www ~]# curl -s -o /dev/null -I -w "%{http_code}\n" http://www.etiantian.org/abc/