nginx 配置 https 報錯問題

2021-09-22 19:35:29 字數 840 閱讀 9030

問題描述

用 nginx 配置 https 時,需要配置 443 埠、私鑰路徑、證書路徑。會報錯如下:

root@vm-173-231-ubuntu:~# nginx -t

nginx: [emerg] bio_new_file(

"/usr/local/nginx/conf/1_yculcy.cn_bundle.crt"

) failed (ssl: error:02001002:system library:fopen:no such file or directory:fopen(

'/usr/local/nginx/conf/1_yculcy.cn_bundle.crt','r'

) error:2006d080:bio routines:bio_new_file:no such file)

nginx: configuration file /etc/nginx/nginx.conf test failed

如下圖:

報錯提示配置檔案有錯誤,找不多私鑰和證書。

解決方案

最終發現,無論windows還是linux,只要寫絕對路徑,就會報錯。

所以:

在 windows 下,將證書檔案等放到 nginx/conf/ 目錄下,配置檔案中,不用加路徑;

在 linux 下,可以將證書檔案等放到 nginx.conf 同級目錄下,不加路徑即可,或者也可以放到 nginx/conf/ 目錄下,可以加相對路徑。

nginx 配置https證書

安裝證書 檔案說明 1.證書檔案214467769540415.pem,包含兩段內容,請不要刪除任何一段內容。2.如果是證書系統建立的csr,還包含 證書私鑰檔案214467769540415.key。2 開啟 nginx 安裝目錄下 conf 目錄中的 nginx.conf 檔案,找到 3 將其修...

nginx配置https協議

一 我們用的是阿里雲的伺服器,所以直接在管理中心生成網域名稱對應的.pem和.key檔案,放在伺服器指定資料夾內,我放在cert資料夾內 二 開啟 etc nginx nginx.conf,以下是寫在http 內 upstream test server 設定檢視nginx狀態的位址 locatio...

nginx 配置 https 服務

一 環境 1 centos 7 2 nginx 安裝前保證自己的nginx處於開啟的狀態並且可通過網域名稱訪問80埠即可。我nginx一般是用作反向 的,所以在生成證書前不需要單獨配置新的網域名稱服務,使用安裝後預設的配置服務即可。二 證書使用 let s encrypt 安裝證書管理客戶端 1 w...