成人午夜视频全免费观看高清-秋霞福利视频一区二区三区-国产精品久久久久电影小说-亚洲不卡区三一区三区一区

Nginx下升級https的方法步驟

購買證書

成都創(chuàng)新互聯(lián)公司堅(jiān)持“要么做到,要么別承諾”的工作理念,服務(wù)領(lǐng)域包括:成都網(wǎng)站設(shè)計(jì)、做網(wǎng)站、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣等服務(wù),滿足客戶于互聯(lián)網(wǎng)時(shí)代的魯山網(wǎng)站設(shè)計(jì)、移動(dòng)媒體設(shè)計(jì)的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡(luò)建設(shè)合作伙伴!

可以去阿里云的云盾證書服務(wù)購買

下載證書

在證書控制臺下載 Nginx 版本證書。下載到本地的壓縮文件包解壓后包含:

  • .pem 文件:證書文件
  • .key 文件:證書的私鑰文件(申請證書時(shí)如果沒有選擇 自動(dòng)創(chuàng)建CSR ,則沒有該文件)

配置Nginx

1、在 Nginx 的安裝目錄下創(chuàng)建 cert 目錄,并且將下載的全部文件拷貝到 cert 目錄中,如果申請證書時(shí)是自己創(chuàng)建的CSR文件,請將對應(yīng)的私鑰文件放到 cert 目錄下。

2、打開 Nginx 安裝目錄下 conf 目錄中的 nginx.conf 文件

#user nobody;
worker_processes 1;

#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

#pid    logs/nginx.pid;

events {
  worker_connections 1024;
}

http {
  include    mime.types;
  default_type application/octet-stream;

  #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
  #         '$status $body_bytes_sent "$http_referer" '
  #         '"$http_user_agent" "$http_x_forwarded_for"';

  #access_log logs/access.log main;

  sendfile    on;
  #tcp_nopush   on;

  #keepalive_timeout 0;
  keepalive_timeout 65;

  gzip on;  #開啟gzip
  gzip_min_length 1k; #低于1kb的資源不壓縮
  gzip_comp_level 3; #壓縮級別【1-9】,越大壓縮率越高,同時(shí)消耗cpu資源也越多,建議設(shè)置在4左右。
  gzip_types text/plain application/javascript application/x-javascript text/javascript text/xml text/css; #需要壓縮哪些響應(yīng)類型的資源,多個(gè)空格隔開。不建議壓縮圖片,下面會(huì)講為什么。
  gzip_disable "MSIE [1-6]\."; #配置禁用gzip條件,支持正則。此處表示ie6及以下不啟用gzip(因?yàn)閕e低版本不支持)
  gzip_vary on; #是否添加“Vary: Accept-Encoding”響應(yīng)頭

  server {
    listen    80 default backlog=2048; #配置http可用
    listen    443 ssl; #配置https
    server_name localhost;

    ssl_certificate   ../cert/hzzly.pem; #配置證書文件
    ssl_certificate_key ../cert/hzzly.key; #配置私鑰文件

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

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

    location / {
      root  /home/hzzly;
      index index.html index.htm;
    }

    # location ^~ /apis/ {
    #   proxy_set_header Host $host;
    #   proxy_set_header X-Real-IP $remote_addr;
    #   proxy_set_header X-Forwarded-Server $host;
    #   # 匹配任何以 /apis/ 開始的請求,并停止匹配 其它location
    #   proxy_pass http://xxxxxxxxxx/;
    # }

    # location ^~ /assets/ {
    #   gzip_static on;
    #   expires max;
    #   add_header Cache-Control public;
    # }
  }
}

3、重啟 Nginx

$ cd /usr/local/nginx/sbin
$ ./nginx -s reload

錯(cuò)誤詳解

1、Nginx如果未開啟SSL模塊,配置Https時(shí)提示錯(cuò)誤

nginx: [emerg] the "ssl" parameter requires ngx_http_ssl_module in ...

Nginx開啟SSL模塊

切換到源碼包:

$ cd /usr/local/src/nginx-1.16.0

修改新的configure參數(shù)

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

配置完成后,運(yùn)行命令

$ make //這里不要進(jìn)行make install,否則就是覆蓋安裝

備份原有已安裝好的nginx

$ cp /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bak

將剛剛編譯好的nginx覆蓋掉原有的nginx

$ cp ./objs/nginx /usr/local/nginx/sbin/

重啟 Nginx

$ cd /usr/local/nginx/sbin
$ ./nginx -s reload

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持創(chuàng)新互聯(lián)。

網(wǎng)頁名稱:Nginx下升級https的方法步驟
文章位置:http://jinyejixie.com/article22/johicc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供微信公眾號、全網(wǎng)營銷推廣品牌網(wǎng)站制作、響應(yīng)式網(wǎng)站網(wǎng)站建設(shè)、搜索引擎優(yōu)化

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

綿陽服務(wù)器托管
南丰县| 西乡县| 崇礼县| 井陉县| 临清市| 玉山县| 清水河县| 莱阳市| 伊春市| 房产| 天门市| 通辽市| 县级市| 施甸县| 东明县| 肥城市| 玛沁县| 曲麻莱县| 新兴县| 交口县| 当雄县| 分宜县| 独山县| 克拉玛依市| 海丰县| 苍山县| 惠水县| 沙河市| 乐亭县| 旅游| 太白县| 那曲县| 吴川市| 新沂市| 平度市| 讷河市| 五原县| 得荣县| 公安县| 湟源县| 灵宝市|