否"ssl_certificate"为"listen ... ssl"定义指示 [英] no "ssl_certificate" is defined for the "listen ... ssl" directive
问题描述
我正在尝试为我的网站配置nginx服务器.我正在使用以下代码来配置我的服务器.如果我为www.fastenglishacademy.fr(443)服务器块添加default_server,它会起作用.
但是在那种情况下,我所有的子域也带来了www.fastenglishacademy.fr的内容
如果删除default_server,则会出现以下错误:
nginx: [emerg] 没有为/etc/nginx/sites-enabled/fastenglishacademy.fr.conf:14 中的listen ... ssl"指令定义ssl_certificate"nginx:配置文件/etc/nginx/nginx.conf测试失败
我的nginx配置代码:
服务器{听80;听[::]:80;server_name fastenglishacademy.fr;返回301 https://www.fastenglishacademy.fr$request_uri;}服务器 {听80;听[::]:80;server_name www.fastenglishacademy.fr;返回301 https://www.fastenglishacademy.fr$request_uri;}服务器 {监听443 SSL http2;听[::]:443 SSL http2;server_name fastenglishacademy.fr;返回301 https://www.fastenglishacademy.fr$request_uri;}服务器 {监听443 SSL http2;听[::]:443 SSL http2;根目录/media/fea/www/fastenglishacademy.com;index index.html index.htm index.nginx-debian.html;server_name www.fastenglishacademy.fr;地点/{继续try_files $ uri $ args $ uri $ args//index.html;}位置〜* \.(jpg | jpeg | png | gif | ico | ttf | woff2 | woff | svg)$ {365天到期;}位置〜* \.(css | js)$ {到期30天;}位置 ~* \.(pdf)$ {15d 到期;}#Warning:在添加以下行之前,请先阅读!add_header严格传输安全性"max-age = 31536000; includeSubDomains"始终;add_header X-Frame-Options DENY;add_header X-Content-Type-Options nosniff;#SSL证书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_certificate
和 ssl_certificate_key
声明.>
您需要具有一个 .crt
和一个 .key
文件才能与ssl一起运行.
它应该看起来像
服务器{听80;监听443 default_server ssl;ssl_certificate/etc/nginx/certs/default.crt;ssl_certificate_key/etc/nginx/certs/default.key;...其他声明}
I am trying to configure nginx server for my website. I am using the following code to configure my server. It works if I add default_server for my www.fastenglishacademy.fr (443) server block.
But in that case, All my subdomains also brings the content of www.fastenglishacademy.fr
And if I remove the default_server, I get the following error:
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
My nginx configuration codes:
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;
}
My links:
https://www.fastenglishacademy.fr/
https://api.fastenglishacademy.fr/
Your server
section is missing ssl_certificate
and ssl_certificate_key
declarations.
You need to have a .crt
and a .key
file to run with ssl.
It should looks like
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_certificate"为"listen ... ssl"定义指示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!