馬哥教育網絡21期+第十二周練習博客中

4、建立httpd服務器(基于編譯的方式進行),要求:
 提供兩個基于名稱的虛擬主機:
(a)www1.stuX.com,頁面文件目錄為/web/vhosts/www1;錯誤日志為/var/log/httpd/www1.err,訪問日志為/var/log/httpd/www1.access;
(b)www2.stuX.com,頁面文件目錄為/web/vhosts/www2;錯誤日志為/var/log/httpd/www2.err,訪問日志為/var/log/httpd/www2.access;
(c)為兩個虛擬主機建立各自的主頁文件index.html,內容分別為其對應的主機名;
(d)通過www1.stuX.com/server-status輸出httpd工作狀態相關信息,且只允許提供帳號密碼才能訪問(status:status);
啟用虛擬主機需要將中心主機禁用:
并啟用:NameVirtualHost *:80
這里實驗出現一點問題,在DocumentRoot中的文件路徑修改的時候,Directory沒有進行更改,在給出沒有確定網址的時候,會跳轉至系統默認的歡迎頁面,這里需要注意的是:Directory在全局定義的時候對虛擬主機是不生效的,需要在虛擬主機中重新進行定義;
現在基本配置完成:
<VirtualHost 172.16.0.3:80>
   ServerName www1.stuX.com
   DocumentRoot "/wanghongkai/web1/host"
   ErrorLog "/var/log/www1.err"
   CustomLog "/var/log/www1.access" common
</VirtualHost>
<VirtualHost 172.16.0.3:80>
   ServerName www2.stuX.com
   DocumentRoot "/wanghongkai/web2/host"
   ErrorLog "/var/log/www1.err"
   CustomLog "/var/log/www1.access" common
</VirtualHost>
基于認證模式訪問內置的頁面server-status
<VirtualHost 172.16.0.3:80>
   ServerName www1.stuX.com
   DocumentRoot "/wanghongkai/web1/host"
   ErrorLog "/var/log/www1.err"
   CustomLog "/var/log/www1.access" common
   <Location /server-status>
    AuthType Basic
    AuthName "only for Admin"
    AuthUserFile /etc/httpd/conf.d/.htpasswd
    SetHandler server-status
    Require valid-user
   </Location>
</VirtualHost>
<VirtualHost 172.16.0.3:80>
   ServerName www2.stuX.com
   DocumentRoot "/wanghongkai/web2/host"
   ErrorLog "/var/log/www1.err"
   CustomLog "/var/log/www1.access" common
</VirtualHost>
#<VirtualHost 172.16.0.3:80>
#  ServerName www1.stuX.com
#  DocumentRoot "/wanghongkai/web1/host"
#</VirtualHost>



5、為第4題中的第2個虛擬主機提供https服務,使得用戶可以通過https安全的訪問此web站點;
(1)要求使用證書認證,證書中要求使用的國家(CN)、州(HA)、城市(ZZ)和組織(MageEdu);
(2)設置部門為Ops,主機名為www2.stuX.com,郵件為admin@stuX.com;
1,按照/etc/pki/tls/openssl.conf配置文件創建serial和index.txt文件
2,生成CA的私鑰文件:
[root@ns1 CA]# (umask 077; openssl genrsa -out private/cakey.pem 2048)
3,生成公鑰文件:
[root@ns1 CA]# openssl req -x509 -new -key private/cakey.pem -days 7300 -out cacert.pem 
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:CN
State or Province Name (full name) []:HA
Locality Name (eg, city) [Default City]:ZZ
Organization Name (eg, company) [Default Company Ltd]:Magf^C
[root@ns1 CA]# openssl req -x509 -new -key private/cakey.pem -days 7300 -out cacert.pem 
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:CN
State or Province Name (full name) []:HA
Locality Name (eg, city) [Default City]:ZZ
Organization Name (eg, company) [Default Company Ltd]:MageEdu
Organizational Unit Name (eg, section) []:Ops
Common Name (eg, your name or your server's hostname) []:ca.Mageud.com
Email Address []:admin@magedu.com
4,進入客戶端進入/etc/httpd目錄下創建ssl目錄生成公鑰文件和私鑰文件:
[root@ns2 ssl]# (umask 077; openssl genrsa -out httpd.key 2048)
[root@ns2 ssl]# openssl req -new -key httpd.key -days 365 -out httpd.csr
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:CN
State or Province Name (full name) []:HA
Locality Name (eg, city) [Default City]:ZZ
Organization Name (eg, company) [Default Company Ltd]:MageEdu
Organizational Unit Name (eg, section) []:Ops
Common Name (eg, your name or your server's hostname) []:www.stux.com
Email Address []:admin@stux.com

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
5,將申請發送給CA認證機構:
6,CA主機對證書進行簽發:
[root@ns1 CA]# openssl ca -in /tmp/httpd.csr -out /etc/pki/CA/newcerts/httpd.crt -days 365
Using configuration from /etc/pki/tls/openssl.cnf
Check that the request matches the signature
Signature ok
Certificate Details:
    Serial Number: 1 (0x1)
    Validity
        Not Before: Sep 23 18:31:40 2016 GMT
        Not After : Sep 23 18:31:40 2017 GMT
    Subject:
        countryName               = CN
        stateOrProvinceName       = HA
        organizationName          = MageEdu
        organizationalUnitName    = Ops
        commonName                = www.stux.com
        emailAddress              = admin@stux.com
    X509v3 extensions:
        X509v3 Basic Constraints: 
            CA:FALSE
        Netscape Comment: 
            OpenSSL Generated Certificate
        X509v3 Subject Key Identifier: 
            89:AA:21:62:10:CA:AE:E6:A9:08:36:88:19:DF:25:23:8E:84:C8:4B
        X509v3 Authority Key Identifier: 
            keyid:75:F9:01:4A:B9:6F:7E:6B:1B:6B:BE:FC:4A:19:E6:09:44:75:CE:C6

Certificate is to be certified until Sep 23 18:31:40 2017 GMT (365 days)
Sign the certificate? [y/n]:y


1 out of 1 certificate requests certified, commit? [y/n]y
Write out database with 1 new entries
Data Base Updated
7,將證書發還給客戶端:
[root@ns1 CA]# scp /etc/pki/CA/newcerts/httpd.crt root@172.16.0.4:/etc/httpd/ssl/


原創文章,作者:wostop,如若轉載,請注明出處:http://www.www58058.com/51802

(0)
wostopwostop
上一篇 2016-10-17 08:36
下一篇 2016-10-17 08:36

相關推薦

  • Trie樹:應用于統計和排序

    1. 什么是trie樹 1.Trie樹 (特例結構樹)         Trie樹,又稱單詞查找樹、字典樹,是一種樹形結構,是一種哈希樹的變種,是一種用于快速檢索的多叉樹結構。典型應用是用于統計和排序大量的字符串(但不僅限于字符串),所以經常被搜索引擎系統用于文本詞頻統計。它的優點是:最大限度地減少…

    Linux干貨 2015-04-08
  • Nginx+Keepalived實現站點高可用

    Nginx+Keepalived實現站點高可用 vrrp 虛擬路由冗余協議(Virtual Router Redundancy Protocol,簡稱VRRP)是由IETF提出的解決局域網中配置靜態網關出現單點失效現象的路由協議,1998年已推出正式的RFC2338協議標準。VRRP廣泛應用在邊緣網絡中,它的設計目標是支持特定情況下IP數據流量失敗轉移不會引…

    Linux干貨 2016-11-07
  • Linux系統命令使用格式已經如何查看幫助

    在Linux 系統中有非常多的命令一般的命令格式:“COMMAND OPTIONS ARGUMENTS” 下面有一些基礎命令可以體驗下命令的基本格式用法 ifconfig命令    作用: 配置網絡接口,查看網絡接口信息    基本語法:     ifconfig  […

    Linux干貨 2016-08-15
  • 第九周腳本練習

    1、寫一個腳本,判斷當前系統上所有用戶的shell是否為可登錄shell(即用戶的shell不是/sbin/nologin);分別這兩類用戶的個數;通過字符串比較來實現; awk -F: ‘{if($NF!=”/sbin/nologin”) print $1}’ /etc/passwd | wc -l 2、寫一個腳本 (1) 獲取當前主機的主機名,保存于ho…

    Linux干貨 2017-03-30
  • Cobbler 自動化部署系統

    本人較懶,做好筆記,預排版,打印成 PDF 了。-_## Cobbler 自動化部署系統.pdf

    Linux干貨 2015-08-17
  • 用戶 組 和權限 以及權限的 分類

    關于文件的安全我們要從3A驗證 說起     1  Authentication:認證      2  Authorization:授權      3  Accouting|Audition:審計 由于系統文件的用戶太多為了便于管理 我們便把系統的用…

    系統運維 2016-08-04

評論列表(1條)

  • 馬哥教育
    馬哥教育 2016-10-24 22:58

    請完成題目要求所有細節所要求的知識點

欧美性久久久久