題目 實現一個web服務器
在server0上配置一個站點http://server0.example.com,然後執行以下步驟:
- 從http://classroom.example.com/materials/station.html
下載文件,並且
- 將文件重命名爲index.html,絕對不能修改此文件的內容。
- 將index.html拷貝到你的web服務器的DocumentRoot目錄下。
- 來自example.com 172.25.0.0/24域的客戶端可以訪問此web站點。
- 來自my133t.org 172.17.10.0/24域的客戶端拒絕訪問此web站點。
備註: 網站的DocumentRoot如果題目沒有指定,那麼隨意.
操作
安裝httpd包,啓動httpd服務,並設置開機啓動。
[root@server0 ~]# yum install -y httpd [root@server0 ~]# systemctl start httpd [root@server0 ~]# systemctl enable httpd
下載相應文件到網站根目錄。這裏默認的網站根目錄是
/var/www/html
[root@server0 ~]# wget -O /var/www/html/index.html http://classroom.example.com/materials/station.html
配置防火牆,限制訪問
[root@server0 ~]# firewall-cmd --permanent --add-rich-rule 'rule family=ipv4 source address=172.25.0.0/24 service name=http accept' [root@server0 ~]# firewall-cmd --permanent --add-rich-rule 'rule family=ipv4 source address=172.17.10.0/24 service name=http reject' [root@server0 ~]# firewall-cmd --reload
另外httpd服務配置也可以做這個限制。這個回頭再寫。