Nginx伺服器配置對https的支援

來源:互聯網
上載者:User

標籤:linux   nginx   https   

1、安裝
nginx要安裝http_ssl_module模組,需要OpenSSL庫和相關的開發包,因此在安裝前,必須安裝這些支援
在centos系統下,直接用yum安裝即可:# yum install openssl openssl-devel
編譯nginx
# tar -zxvf pcre-8.12.tar.gz
# cd pcre-8.12
# ./configure –prefix=/usr/local
# make
# make install
# tar -zxvf nginx-1.0.0.tar.gz
# cd nginx-1.0.0
# ./configure –prefix=/usr/local/nginx –user=www –group=www –with-http_ssl_module –with-pcre
# make
# make install

2、製作密匙(單項認證)
# mkdir /usr/local/nginx/ssl
# cd /usr/local/nginx/ssl
# openssl genrsa -des3 -out server.key 1024   (建立伺服器私密金鑰,在這個過程中需要輸入密碼短語,需要記住這個密碼)
# openssl req -new -key server.key -out server.csr
輸入命令以後,需要填寫如下內容:
Country Name(國家:中國填寫CN)
State or Province Name(地區或是省份:CHONGQING)
Locality Name(地區局部名字:CHONGQING)
Organization Name(機構名稱:填寫公司名)
Organizational Unit Name(組織單位名稱:部門名稱)
Common Name(網站網域名稱)
Email Address(郵箱地址)
A challenge password(輸入一個密碼)
An optional company name(一個可選的公司名稱)
輸入完這些內容,就會在目前的目錄產生server.csr檔案
# cp server.key server.key.org
# openssl rsa -in server.key.org -out server.key  (對於使用上面的私密金鑰啟動具有SSL功能的NGINX)
# openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt  (使用上面的密鑰和CSR對認證進行簽

名)

3、配置NGINX
編輯需要使用HTTPS的網域名稱的NGINX設定檔(上面填寫的Common Name網站網域名稱)
server {
 listen 443;
 server_name www.xxx.com;
 ssl on;
 ssl_certificate /usr/local/nginx/ssl/server.crt;
 ssl_certificate_key /usr/local/nginx/ssl/server.key;
}

儲存,重啟NGINX,這樣就搭建了一個簡單的https服務的網站(單項認證)

Nginx伺服器配置對https的支援

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.