实验环境
•一台最小化安装的CentOS 7.3虚拟机
•配置:1核心/512MB
•nginx版本1.12.2
一、配置盗链网站
1.启动一台nginx虚拟机,配置两个网站
vim /etc/nginx/conf.d/vhosts.conf
添加以下内容
server { listen 80; server_name site1.test.com; root /var/wwwroot/site1; index index.html; location / { }}server { listen 80; server_name site2.test.com; root /var/wwwroot/site2; index index.html; location / { }}
2.在宿主机编辑C:/Windows/System32/drivers/etc/hosts文件
192.168.204.11 site1.test.com
192.168.204.11 site2.test.com
3.创建网站根目录
mkdir /var/wwwrootcd /var/wwwrootmkdir site1mkdir site2echo -e "<h1>site1</h1><img src='1.jpg'>" >> site1/index.htmlecho -e "<h1>site2</h1><img src='http://site1.test.com/1.jpg'>" >> site2/index.html
4.将1.jpg上传到/var/wwwroot/site1目录
5.启动nginx服务
systemctl restart nginxnetstat -anpt | grep nginx
6.防火墙放通80端口
setenforce 0firewall-cmd --zone=public --add-port=80/tcp --permanentfirewall-cmd --reload
7.在宿主机访问
http://site1.test.com
http://site2.test.com
新闻热点
疑难解答