您好,登錄后才能下訂單哦!
KeepAlive
KeepAlive' Timeout
作用
使用Require
配置項實現訪問控制,按先后順序限制
可用于<Location>、<Directory>、<Files>、 <Limit>
配置段中
Require
配置項的常見語法Require all granted
Require all denied
Require local
Require [not] host <主機名或域名列表>
//使用not禁止訪問時要將其置于<RequireAll> </RequireAll>容器中并在容器中指定相應的限制策略
Require [not] ip <IP地址或網段列表>
在Linux
系統中安裝DNS、HTTP
服務,并設置DNS
服務。
[root@localhost ~]# yum install bind httpd -y //安裝服務
已加載插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
...//省略部分內容...
已安裝:
bind.x86_64 32:9.11.4-9.P2.el7 httpd.x86_64 0:2.4.6-90.el7.centos
...//省略部分內容...
完畢!
[root@localhost conf]# vim /etc/named.conf //編輯DNS配置文件
...//省略部分內容...
options {
listen-on port 53 { any; }; //更改IP地址為any
listen-on-v6 port 53 { ::1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
recursing-file "/var/named/data/named.recursing";
secroots-file "/var/named/data/named.secroots";
allow-query { any; }; //更改監聽主機為any
...//省略部分內容...
:wq
[root@localhost conf]# vim /etc/named.rfc1912.zones //編輯區域配置文件
...//省略部分內容...
zone "kgc.com" IN { //更改域名
type master;
file "kgc.com.zone"; //更改區域數據文件名
allow-update { none; };
};
...//省略部分內容...
:wq
[root@localhost conf]# cd /var/named/ //進入區域數據文件目錄
[root@localhost named]# ls //查看目錄
data dynamic named.ca named.empty named.localhost named.loopback slaves
[root@localhost named]# cp -p named.localhost kgc.com.zone //復制區域數據文件
[root@localhost named]# vim kgc.com.zone //進入編輯文件
$TTL 1D
@ IN SOA @ rname.invalid. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS @
A 127.0.0.1
www IN A 192.168.144.133 //設置域名解析
:wq //保存退出
開啟兩臺win 10客戶機,并查看客戶機IP地址
在Linux系統中進入http服務站點目錄,編輯主頁內容,并開啟DNS、HTTP服務,關閉防火墻及增強性安全功能
[root@localhost named]# cd /var/www/html/ //進入http服務站點目錄
[root@localhost html]# vim index.html //編輯默認主頁
<h2>this is kgc web</h2> //編輯內容
:wq
[root@localhost html]# ls //查看
index.html
[root@localhost html]# cat index.html //查看網頁內容
<h2>this is kgc web</h2>
[root@localhost html]# systemctl start httpd.service //啟動http服務
[root@localhost html]# systemctl start named //啟動DNS服務
[root@localhost html]# systemctl stop firewalld.service //關閉防火墻
[root@localhost html]# setenforce 0 //關閉增強性安全功能
使用兩臺win 10客戶機分別訪問往網站信息,看服務是否正常提供
在Linux系統中配置HTTP服務配置文件,設置客戶機訪問權限
[root@localhost html]# vim /etc/httpd/conf/httpd.conf
//編輯主配置文件內容(現網中不建議直接修改主配置文件內容,可以重新添加子配置文件進行限制)
...//省略部分內容...
<Directory "/var/www/html">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.4/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride None
#
# Controls who can get stuff from this server.
#
<RequireALL> //在此容器下添加子容器
Require not ip 192.168.144.128
//添加限制訪問主機的IP地址(如若限制網段直接添加192.168.144.0/24即可,注意限制網段需填寫子網掩碼)
Require all granted
</RequireALL>
</Directory>
...//省略部分內容...
:wq
[root@localhost html]# systemctl restart httpd.service
查看限制的第一臺win 10客戶端是否還可以訪問網站
創建用戶認證數據庫
[root@localhost html]# htpasswd -c /etc/httpd/conf/pwd test01
//創建用戶認證數據庫(-c為創建,如果已經存在數據認證文件可以不用-c,直接就可以使用命令添加進認證文件中)
New password: //輸入設置的密碼
Re-type new password: //再次輸入密碼
Adding password for user test01 //成功創建
[root@localhost html]# cd /etc/httpd/conf //進入目錄
[root@localhost conf]# ls //查看
httpd.conf magic pwd //成功創建文件
[root@localhost conf]# cat pwd //查看文件內容
test01:$apr1$zDZ/54yz$rUCXaWixaltHE6ZBvjv0h/ //創建的用戶及密碼
添加用戶授權配置
[root@localhost conf]# vim httpd.conf
...//省略部分內容...
<Directory "/var/www/html">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.4/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride None
#
# Controls who can get stuff from this server.
#
AuthName "DocumentRoot" //更改上面的訪問控制條目,此條目聲明驗證信息
AuthType Basic //驗證類型為基本驗證
AuthUserFile /etc/httpd/conf/pwd //驗證文件路徑
Require valid-user //設置為授權用戶驗證
</Directory>
...//省略部分內容...
:wq //保存退出
[root@localhost conf]# systemctl restart httpd.service //重新啟動服務
在客戶機中驗證配置
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。