linux nginx 認證配置 https__linux

來源:互聯網
上載者:User

配置前提nginx裝了SSL功能模組。

[root@www conf]# openssl genrsa -out cert.key2 2048         產生cert.key2私密金鑰檔案  
Generating RSA private key, 2048 bit long modulus
......................+++
..................................................................................+++
e is 65537 (0x10001)
[root@www conf]# openssl req -new -x509 -key cert.key2 -out cert.pem2    用cert.key2 產生 cert.pem2認證檔案
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) []:
Locality Name (eg, city) [Default City]:
Organization Name (eg, company) [Default Company Ltd]:
Organizational Unit Name (eg, section) []:                            慢點。。。。下面要輸入東西了。
Common Name (eg, your name or your server's hostname) []:www.wang.com     #輸你的網域名稱

Email Address []:

vim /usr/local/nginx/conf/nginx.conf     編輯設定檔 添加一個 server 可以複製我的在修修改改。 

   server {
        listen       443;        連接埠號碼要改。
        server_name  www.wang.com;    網域名稱要改。
        ssl on;
        ssl_certificate      /usr/local/nginx/conf/cert.pem2;          認證檔案 路徑寫好。
        ssl_certificate_key  /usr/local/nginx/conf/cert.key2;         私密金鑰檔案 路徑寫好。


        ssl_session_cache    shared:SSL:1m;
        ssl_session_timeout  5m;


        ssl_ciphers  HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers  on;   


        location / {
            root   /var/www/html/web1;        你的網站目錄,最好寫絕對路徑。
            index  index.html index.htm;        首頁檔案。
        }
    }


防火牆添加一條允許443連接埠的命令。

弄好了 把nginx重啟 重載有時候不行,弄好了用

netstat-anput |grep nginx

看一下 nginx是不是監聽的443連接埠。

防火牆,核心防火牆 關。

訪問。




ok。


聯繫我們

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