RHCE練習題 12. 配置一個web伺服器
阿新 • • 發佈:2019-02-01
題目 實現一個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服務配置也可以做這個限制。這個回頭再寫。