apache下mod_gnutls實現多HTTPS虛擬機器主機

來源:互聯網
上載者:User

多HTTPS虛擬機器主機的配置。那麼在apache的環境下該如何配置呢?利用的原理的都是同一個,也就是SNI。基於網域名稱的虛擬機器主機,即共用同一個IP地址和連接埠的HTTPS虛擬機器主機。

SNI—伺服器名稱指示,是一個TLS的擴充,它使得啟用SSL的基於網域名稱的虛擬機器主機的配置成為可能。打破了每個HTTPS的虛擬機器主機需要一個IP地址的要求。因此,成本大大降低,因為所有的HTTPS虛擬機器主機可以共用相同的IP地址和連接埠,使HTTPS Web服務的更簡單。

在apache環境下,需要使用mod_gnutls來實現同一個IP上配置多個HTTPS主機。下面來看看實現過程:

mod_gnutls的網址參見:https://mod.gnutls.org

1. 安裝mod_gnutls

 代碼如下 複製代碼

# yum install httpd-devel gnutls-devel
# wget http://www.outoforder.cc/downloads/mod_gnutls/mod_gnutls-0.2.0.tar.bz2
# tar -xjvf mod_gnutls-0.2.0.tar.bz2
# cd mod_gnutls-0.2.0
# ./configure --prefix=/usr
# make

如果要安裝高版本的gnutls的話,需要先安裝相對應的依賴包libnettle gmplib。下載地址:http://www.gnutls.org/download.html  ftp://ftp.gnutls.org/gcrypt/gnutls

2.  apache載入mod_gnutls模組

 代碼如下 複製代碼

# cp mod_gnutls-0.2.0/src/.libs/libmod_gnutls.so /usr/lib/httpd/modules/mod_gnutls.so
# cp mod_gnutls-0.2.0/data/{dh,rsa}file /etc/httpd/conf/

3. 配置httpd.conf

 代碼如下 複製代碼

Listen 10.1.1.22:443
LoadModule gnutls_module modules/mod_gnutls.so
AddType application/x-x509-ca-cert .crt
AddType application/x-pkcs7-crl    .crl
GnuTLSCache dbm "/var/cache/mod_gnutls_cache"
GnuTLSCacheTimeout 300
NameVirtualHost 10.1.1.22:443


4. 配置虛擬機器主機

 

 代碼如下 複製代碼

<VirtualHost 10.1.1.22:443>
    ServerName 你的網域名稱2:443
    GnuTLSEnable on
    GnuTLSCertificateFile ./ssl/你的網域名稱2.public.cer
    GnuTLSKeyFile ./ssl/你的網域名稱2.private.key
    DocumentRoot "/data/wwwroot/你的網域名稱2/webroot"
</VirtualHost>

<VirtualHost 10.1.1.22:443>
    ServerName 你的網域名稱:443
    GnuTLSEnable on
    GnuTLSCertificateFile ./ssl/你的網域名稱.public.cer
    GnuTLSKeyFile ./ssl/你的網域名稱.private.key
    DocumentRoot "/data/wwwroot/你的網域名稱/webroot"
</VirtualHost>


這樣訪問每個虛擬機器主機都正常。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.