gpt4 book ai didi

ssl - 添加SSL证书配置后无法重启Nginx?

转载 作者:太空宇宙 更新时间:2023-11-03 13:23:34 25 4
gpt4 key购买 nike

我刚刚从 Name.com 购买了 RapidSSL 并尝试通过此链接安装它

https://www.digitalocean.com/community/tutorials/how-to-install-an-ssl-certificate-from-a-commercial-certificate-authority

所以当我跑的时候

sudo service nginx restart

我明白了。

Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.

所以这是我的/etc/nginx/sites-available/default

server {
listen 80;
server_name mydomain.co;
rewrite ^/(.*) https://mydomain.co/$1 permanent;
}

server {
listen 443 ssl;

ssl_certificate ~/key/www.mydomain.co.chained.crt;
ssl_certificate_key ~/key/www.mydomain.co.key;

ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';

server_name mydomain.co;
root /www/mydomain/build;
index index.html index.htm;
rewrite ^/(.*)/$ $1 permanent;

location ~ ^.+\..+$ {
try_files $uri =404;
}

location / {
try_files $uri $uri/ /index.html;
}

location ~ /\. {
deny all;
access_log off;
log_not_found off;
return 404;
}
}

但是当我删除这一行时

ssl_certificate ~/key/www.mydomain.co.chained.crt;

我可以重启nginx。

有人知道如何解决这个问题吗?

谢谢!

最佳答案

您的 nginx 配置文件中的 ~ 可能没有按照您预期的方式工作。我假设您打算将其变为 /home/username/key/www.mydomain.co.chained.crt,但不会那样处理。

要确认这一点,请读取配置行,然后运行 ​​nginx -t。您将看到 nginx 的配置检查错误日志:

nginx: [emerg] BIO_new_file("/etc/nginx/~/key/www.mydomain.co.chained.crt") failed (SSL: error:02001002:system library:fopen:No such file or directory:fopen('/etc/nginx/~/key/www.mydomain.co.chained.crt','r') error:2006D080:BIO routines:BIO_new_file:no such file)

关于ssl - 添加SSL证书配置后无法重启Nginx?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41150486/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com