我正在尝试将我从 Godaddy 获得的 SSL 证书安装到我的 NGINX 服务器上。我很确定我的所有路径都是正确的,并且据我所知,我的服务器配置是正确的,但仍然出现以下错误。
Feb 20 11:06:35 my.server.com nginx[6173]: nginx: [emerg] cannot load certificate "/etc/ssl/certs/certificate.crt": BIO_new_file() failed (SSL: error:0200100D:system library:fopen:Permission denied:fopen('/etc/ssl/certs/certificate.crt','r') error:2006D002:BIO routines:BIO_new_file:system lib)
Feb 20 11:00:01 my.server.com nginx[5969]: nginx: configuration file /etc/nginx/nginx.conf test failed
Run Code Online (Sandbox Code Playgroud)
下面是我的 SSL 配置。我已将其放入路径中的文件中/etc/nginx/conf.d/ssl.conf
。
server {
listen 443 ssl http2 default_server;
listen [::]:443 ssl http2 default_server;
server_name my.server.com;
root /usr/share/nginx/html;
ssl_certificate /etc/ssl/certs/certificate.crt;
ssl_certificate_key /etc/ssl/private/private.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 10m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
proxy_pass http://[MY_IP_ADDRESS]:8443;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
Run Code Online (Sandbox Code Playgroud)
这看起来是一个权限问题,但我已经运行 chown 来更改 root 用户的权限,并且我已经通过 chmod 将文件权限更改为 600。这不正确吗?有人可以就如何解决这个问题给我一些指导吗?
** 更新 **
我确实检查过,发现 SSL 证书不归 root 用户所有。我已将所有 SSL 文件修改为由 root 所有者和组拥有,并将文件权限更改为 600,我尝试了 700。运行时得到以下输出sudo ls -l
-rwx------. 1 root root 7072 Feb 20 10:41 my.server.com.chained.crt
-rwx------. 1 root root 2277 Feb 20 10:36 my.server.com.crt
-rwx------. 1 root root 4795 Feb 20 10:39 intermediate.crt
Run Code Online (Sandbox Code Playgroud)
尽管如此,我仍然遇到同样的错误。我也试过普通证书和全链证书。有谁知道发生了什么?
我终于解决了我的问题。事实证明,当我移动文件 (mv) 时,它更改了文件的安全上下文,从而使 nginx 无法读取它们。我通过在我的 nginx 根文件夹上运行以下命令解决了这个问题。
restorecon -v -R /etc/nginx
Run Code Online (Sandbox Code Playgroud)
我从这篇文章中找到了这个。
感谢所有的帮助!
归档时间: |
|
查看次数: |
9330 次 |
最近记录: |