gpt4 book ai didi

ssl - 没有为 "ssl_certificate"指令定义 "listen ... ssl"

转载 作者:行者123 更新时间:2023-12-04 16:13:04 25 4
gpt4 key购买 nike

我正在尝试为我的网站配置 nginx 服务器。我正在使用以下代码来配置我的服务器。如果我为我的 www.fastenglishacademy.fr (443) 服务器 block 添加 default_server ,它将起作用。

但在这种情况下,我所有的子域也带来了 www.fastenglishacademy.fr 的内容

如果我删除 default_server,我会收到以下错误:

nginx: [emerg] no "ssl_certificate" is defined for the "listen ... ssl" directive in /etc/nginx/sites-enabled/fastenglishacademy.fr.conf:14
nginx: configuration file /etc/nginx/nginx.conf test failed

我的 nginx 配置代码:
server {
listen 80;
listen [::]:80;
server_name fastenglishacademy.fr;
return 301 https://www.fastenglishacademy.fr$request_uri;
}
server {
listen 80;
listen [::]:80;
server_name www.fastenglishacademy.fr;
return 301 https://www.fastenglishacademy.fr$request_uri;
}

server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name fastenglishacademy.fr;
return 301 https://www.fastenglishacademy.fr$request_uri;
}

server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
root /media/fea/www/fastenglishacademy.com;
index index.html index.htm index.nginx-debian.html;
server_name www.fastenglishacademy.fr;
location / {
etag on;
try_files $uri$args $uri$args/ /index.html;
}

location ~* \.(jpg|jpeg|png|gif|ico|ttf|woff2|woff|svg)$ {
expires 365d;
}
location ~* \.(css|js)$ {
expires 30d;
}

location ~* \.(pdf)$ {
expires 15d;
}
#WARNING: Please read before adding the lines below!
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
add_header X-Frame-Options DENY;
add_header X-Content-Type-Options nosniff;

# SSL Certificates
ssl_certificate /path/to/fullchain.pem;
ssl_certificate_key /path/to/privkey.pem;
ssl_trusted_certificate /path/to/chain.pem;
}

我的链接:

https://www.fastenglishacademy.fr/

https://api.fastenglishacademy.fr/

最佳答案

您的 server部分缺失 ssl_certificatessl_certificate_key声明。

你需要有一个 .crt.key使用 ssl 运行的文件。

它应该看起来像

server {

listen 80;

listen 443 default_server ssl;
ssl_certificate /etc/nginx/certs/default.crt;
ssl_certificate_key /etc/nginx/certs/default.key;

... other declarations

}

关于ssl - 没有为 "ssl_certificate"指令定义 "listen ... ssl",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56668320/

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