启动nginx
vim /usr/local/lnmp/nginx/conf/nginx.conf
mkdir /www
cd /www
vim index.html
www.westos.org
mkdir /bbs
cd /bbs
vim index.html
bbs.westos.org
同时,在物理机上加入解析
在页面访问 www.westos.org bbs.westos.org
vim /usr/local/lnmp/nginx/conf/nginx.conf

mkdir /www
cd /www
vim index.html
www.westos.org
mkdir /bbs
cd /bbs
vim index.html
bbs.westos.org
同时,在物理机上加入解析
在页面访问 www.westos.org bbs.westos.org

443加密
vim /usr/local/lnmp/nginx/conf/nginx.conf
cd /etc/pki/tls/certs/
make cert.pem
cp cert.pem /usr/local/lnmp/nginx/conf/
nginx -t
nginx -s reload
vim /usr/local/lnmp/nginx/conf/nginx.conf

cd /etc/pki/tls/certs/
make cert.pem

cp cert.pem /usr/local/lnmp/nginx/conf/
nginx -t
nginx -s reload
测试:访问https://www.westos.org

重定向:
当访问以westos.org或www.westos.org时,重定向到https://www.westos.org
vim /usr/local/lnmp/nginx/conf/nginx.conf
nginx -s reload
当访问以westos.org或www.westos.org时,重定向到https://www.westos.org
vim /usr/local/lnmp/nginx/conf/nginx.conf

nginx -s reload
测试:
在物理机中:
curl -I www.westos.org
curl -I westos.org
在物理机中:
curl -I www.westos.org
curl -I westos.org
当访问www.westos.org后的url时,定向到加密后的
[root@server1 ~]# vim /usr/local/lnmp/nginx/conf/nginx.conf

nginx -s reload
物理机:
curl -I www.westos.org/index.html
curl -I www.westos.org/index.html

当访问www.westos.org/bbs,时重定向到http://bbs.westos.org
vim /usr/local/lnmp/nginx/conf/nginx.conf

nginx -s reload
物理机
curl -I www.westos.org/bbs

当访问www.westos.org/bbs后还有url时,定向到http://bbs.westos.org/index.html
vim /usr/local/lnmp/nginx/conf/nginx.conf

nginx -s reload
物理机
curl -I www.westos.org/bbs/index.html

nginx的反向重定向
vim /usr/local/lnmp/nginx/conf/nginx.conf
nginx -s reload
vim /usr/local/lnmp/nginx/conf/nginx.conf

nginx -s reload
mkdir /www/bbs
vim /www/bbs/index.html
/www/bbs/bss.westos.org
测试
物理机
[root@foundation8 Desktop]# curl -I bbs.westos.org

访问http://www.westos.org/bbs/

nginx里的限制参数
vim /usr/local/lnmp/nginx/conf/nginx.conf

nginx -s reload
物理机
ab -c1 -n 5 http://172.25.8.1/download/vim.jpg
cat /usr/local/lnmp/nginx/logs/access.log

ab -c10 -n 10 http://172.25.8.1/download/vim.jpg
cat /usr/local/lnmp/nginx/logs/access.log
cat /usr/local/lnmp/nginx/logs/access.log

防止域名恶意解析:
vim /usr/local/lnmp/nginx/conf/nginx.conf
nginx -s reload
访问172.25.8.1
