nginx配置https訪問,nginxhttps訪問

來源:互聯網
上載者:User

nginx配置https訪問,nginxhttps訪問

一、準備

      環境:centos6.8

      nginx:1.13.6

二、開始

      首先安裝依賴包:

       yum install -y gcc gcc-c++ autoconf automake make zlib zlib-devel openssl openssl-devel pcre pcre-devel

      開始安裝

      tar -xf nginx-1.13.6.tar.gz

      cd nginx-1.13.6

      ./configure --prefix=/usr/local/nginx --with-pcre --with-http_stub_status_module --with-http_gzip_static_module --with-http_ssl_module

      make && make install 

三、配置https簽署憑證

  建立https認證存放目錄:mkdir cert

      建立私密金鑰:openssl genrsa -des3 -out https.key 1024

      建立簽章要求認證:openssl req -new -key https.key -out https.csr

      在載入SSL支援的Nginx並使用上述私密金鑰時除去必須的口令:

  cp https.key https.key.org

  openssl rsa -in https.key.org -out https.key

  最後標記認證使用上述私密金鑰和CSR和有效期間:openssl x509 -req -days 365 -in https.csr -signkey https.key -out https.crt

四、配置nginx的https

  配置vim nginx.conf

   

 server {

        listen       443 ssl;

        server_name  192.168.2.90;

        ssl_certificate      /usr/local/nginx/cert/https.crt;

        ssl_certificate_key  /usr/local/nginx/cert/https.key;

       #    ssl_session_cache    shared:SSL:1m;

        ssl_session_timeout  5m;

      #    ssl_ciphers  HIGH:!aNULL:!MD5;

    #    ssl_prefer_server_ciphers  on;

    location / {

                     root   html;

            index  index.html index.htm;

        }

    }

五、完成


啟動nginx  :/usr/local/nginx/sbin/nginx

有問題改配置後平滑重啟nginx:/usr/local/nginx/sbin/nginx -s reload

用瀏覽器訪問:https://ip

注意:自己建立的認證瀏覽器會提示危險,選擇通過就可以了。

 

      

聯繫我們

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